Friday, July 31, 2009

How do you store a group of characters, say the 2nd thru 9th in row 2, in a text file as a string in C?

I'm a professional PHP developer, and it's been a long time since C, so I'm not going to run this through a compiler now, but it goes something like this:





#include %26lt;stdio.h%26gt;





int main() {





FILE *fp;


char mystr[] = "This is my very awesome string."


char *myotherstr = %26amp;mystr[1];





fp = fopen("out.txt","w");


fwrite(fp,myotherstr,7);


fclose(fp);





return 0;


}


No comments:

Post a Comment