In C++ if you want to input a string and store it in a char array from index 1 you can do something like this:
ifstream f("data.in");
char a[100];
f.get(a+1,90);
Is there any way you can do this in C (like using fscanf)? Doing this:
fscanf(f,"%s",&a+1);
or this:
fscanf(f,"%s",&(a+1));
doesn't work.
aalready is a pointer, you don't have to use&a+1should work as well&a + 1generates an address 100 bytes beyond the start ofa, because&aischar (*)[100]in this context, and incrementing a pointer by one jumps it by the size of the object being pointed at (which is an array of 100 bytes in this case). A good compiler would also complain about the type mismatch between expectedchar *and actualchar (*)[100].