My code is read a string in line from file and print it and its length on screen. But the length is incorrect (bigger than 1).
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main() {
FILE * file;
file= fopen("data.txt","r");
char* singleLine;
singleLine = (char *) malloc(150* sizeof(char *));
if(file){
while(!feof(file)){
fgets(singleLine,150, file);
puts(singleLine);
printf("length: %ld\n",strlen(singleLine));
}
}
fclose(file);
return 0;
}