-2

I have to read a c code and analyze the code. For example, the number of functions in the code, such as the number of operators. I tried a lots but I'm very new in the Java programming language, i didn't happen. I read a lot of topics, tried to do it with the scanner class, but it didn't happen. Can you help me?

public static void main(String[] args) throws IOException 
{ 
    File file = new File("C:\\main.c"); 
    FileInputStream fileStream = new FileInputStream(file); 
    InputStreamReader input = new InputStreamReader(fileStream); 
    BufferedReader reader = new BufferedReader(input); 

    String line; 




    while((line = reader.readLine()) != null) 
    { 

        String[] operatorsNumbers=line.split("+");
        int operators=operatorsNumbers.length;

    } 

    System.out.println("number of operators" + operators );
} 
Mert
  • 113
  • 1
  • 2
  • 5

1 Answers1

0

Can you post the .C file here? Also, why are you splitting based on "+"? Is it that your C code contains only the + operator? And what exactly are you trying to achieve from parsing the C code? You want a list of all operators, functions used in the C code?

Ashish
  • 209
  • 1
  • 10