If str does not contain the whole line as a string, how will &str[pos] contain the rest of the string, as str only holds the first word as a string?
This prints out a blank line when i enter "test tested testing" into stdin.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char getLine[50];
char str[50];
fgets(getLine,50,stdin);
char *remainderString;
int pos;
sscanf(getLine,"%s%n",str,&pos);
remainderString = &str[pos];
printf("%s\n",remainderString);
return 0;
}
and when I change that with
Code:
remainderString = &getline[pos];
It gives me the remainder string.....
I was just confused with what %n did, I did look it up before i posted.