我必須閱讀交流代碼并分析代碼。比如代碼中函數的數量,比如操作符的數量。我嘗試了很多,但我對 Java 編程語言很陌生,我沒有發生。我閱讀了很多主題,試圖用掃描儀類來做,但沒有發生。你能幫助我嗎?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 );}
1 回答

紅糖糍粑
TA貢獻1815條經驗 獲得超6個贊
你可以在這里發布.C文件嗎?另外,為什么要根據“+”進行拆分?您的 C 代碼是否僅包含 + 運算符?你到底想通過解析 C 代碼來實現什么?您想要 C 代碼中使用的所有運算符、函數的列表嗎?
添加回答
舉報
0/150
提交
取消