Hi
I want to open a file and write data in the following manner.
Header
[LEFT]String 1 String 2
String 3 String 4
String 5 String 6
How to write in this way? I have a lengthy string and am substring it according to my requirement. Whenever i substring it i have to write it to file in the above manner? How?
Thanks
[/LEFT]
This is a very vague question. Please show us
- some sample data - the starting data, what you expect for output
- show us the code you have so far.
hi
It's a very simple question and just need of good understanding. This is the code how i got it.
fopen(fp);
fprintf(fp,"\t\t\t\t\t\tHeader");
fprintf(fp,"\nString1:%s \t\t\t\t\t\tString2:%s", str1,str2);
fclose(fp);
That's it.
Thanks
I have a lengthy string and am substring it according to my requirement. Whenever i substring it i have to write it to file in the above
We don't understand this part, show us an example.
hi
am using the below code to get substring
char* getsubstring(const char* urstr, size_t beginL, size_t len)
{
if (urstr == 0 || strlen(urstr) == 0 || strlen(urstr) < begin || strlen(urstr) < (beginL+len))
return 0;
return strndup(urstr + beginL, len);
}
/* Main Program */
fopen(fp);
fprintf(fp,"\t\t\t\t\t\tHeader");
fprintf(fp,"\nString1:%s \t\t\t\t\t\tString2:%s", getsubstring(str1,10,2), getsubstring(str2,20,2);
fclose(fp);
That's it.