62,614
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
int main() {
int i;
char* filename = "1.txt";
char s[100];
FILE* fp = fopen(filename, "r");
if (fp != NULL) {
while(!feof(fp)) {
fscanf(fp, "%s %d \n", s, &i);
printf("%s %d ", s, i);
if (!strcmp(s, "Long")) {
printf("long\n");
}
if (!strcmp(s, "Int")) {
printf("int\n");
}
}
}
fclose(fp);
return 0;
}
import java.io.*;
public class test {
public static void main(String[] args) {
File file = new File("1.txt");
Reader reader = null;
String strInt = "Int";
try {
reader = new InputStreamReader(new FileInputStream(file));
int tempchar;
while ((tempchar = reader.read()) != -1) {
//String str1 = new String (tempchar);
//if (str1.equals(strInt)) {
System.out.print((char) tempchar);
//}
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
這邊 java code 怎麼加入 if 判斷 Int or Long?
謝謝