This code was for implementing cat in Lin, and when I compiled it, it returned me "tp undefined". When I asked my professor, he said the way I used getline is in C language. I'm confused.
int main(int argc, char*argv[]) {
FILE* file;
for (int i = 1; i < argc; i++) {
file = fopen(argv[i],"w");//
if (file < 0) {
perror("Error, Can't open file!");
return -1;
}
if (file.is_open()) {
string tp;
while (getline(file, tp)) { // c type
printf("%d\n", tp);
}
}
}
fclose(file);
return 0;
}