Hi. I need to read several files without spaces or empty lines between characters.They can have different layouts, such as 1.txt, 2.txt or 3.txt:
1.txt:
t
h
i
s
f
i
l
e
2.txt:
l
i
k
e
t
h
a
t
3.txt:
s o m e t h i n g
l i k e
t h a t
How do i do that ? I Just have the following code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char c ;
FILE *fp;
fp = fopen("1.txt","r");
if(fp == NULL){
puts("Open file failed\n");
exit(-1);
}
while(fscanf(fp,"%c\n",&c)!=EOF){
/*do things with c var*/
}
fclose(fp);
exit(0);
}