I have a C program and in main(), a function is called that returns a string. The string is a long string 600+ chars long, but it only returns the first 240 characters of that string. How can I fix this? Your help is most appreciated Thanks!
Here is the execution of the program:
% a.out
12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 12345678901234567890123456789012345678901234567890 1234567890123456789012345678901234567890
... piped into word count it counts 242 characters (probably including CR, LF)...
% a.out | wc
1 1 242
Here is the function...
Code:
/*----------------------------------------------------------------------------*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*---------------------------------------------------------
main program start here
---------------------------------------------------------*/
main(argc, argv)
int argc;
char *argv[];
{
char str_val[800];
memset(str_val,'\0',800);
sprintf(str_val, "%s", getstr2());
printf("%s\n",str_val);
exit(0);
} /* main */
int getstr2()
{
char tmp_str[800];
int i;
memset(tmp_str, '\0', 800);
sprintf(tmp_str, "%s", "1234567890");
for ( i=0; i<59; i++)
strcat(tmp_str, "1234567890");
strcat(tmp_str, "xyz.");
return(tmp_str);
}