-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
  • 63
  • 1
  • 2
  • 4

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
  • exactly yes. the names and parameters of the functions, operator numbers are required to list. The c code is not important. it needs to work for all c codes. I passed the c code to a string variable, but I couldn't write anything for the function names. – Mert Feb 27 '19 at 23:35
  • someone help me :( – Mert Feb 28 '19 at 12:22