Hi
I'm running this on a mac and when i use '\n' it prints the entire contents of the pointed to text file. looking for '\r' just cause an infinite loop. Any idea what the problem might be?
#include <stdio.h>
#include <stdlib.h>
int main(void){
FILE * input;
char * nlptr;
long position;
long count;
char ch;
int name[81];
fprintf(stdout, "please enter a text file\n");
fgets(name, 81, stdin);
nlptr = strchr(name, '\n');
if(nlptr)
*nlptr ='\0';
input = fopen(name, "r");
printf("enter a file position\n");
fscanf(stdin, "%d", &position);
while(getchar() != '\n')
continue;
for(count = position; getc(input) != '\n'; count++){
fseek(input, count, SEEK_SET);
ch = getc(input);
putc(ch, stdout);
}
fclose(input);
printf("\n");
return 0;
}
Thanks to anyone who can help