This is the function
int count_lines(char *text) {
printf("Testing count lines :D \n");
char *result;
int return_lines = 0;
result = strtok(text,"\n");
while(result != NULL) {
return_lines+= 1;
result = strtok(NULL,"\n");
}
return return_lines;
}
Example how i use the function
int main(){
int lines = count_lines("This is a simple game lets enjoy this\nIt breaks a new era in to games\nwhahahaha zoom in");
printf("Line Count : %i \n", lines);
return 0;
}
Compiler Errors
In function 'count_lines':
warning: implicit declaration of function 'strtok'
warning: assignment makes pointer from integer without a cast
warning: assignment makes pointer from integer without a cast