![]() |
Something Loopy in Assigning Strings
I tried this in desperation after strcat() refused to work. I just want to concatenate three strings. Can anyone tell me why this doesn't work? I can see the creation of "10", but not of "11", though there's plenty of room on the disk for both. Moreover, if I ask for a printf of fieldn and strlen(fieldn) for all three fields, I get the right responses. field1[] is more than long enough to handle the job.
Code:
void AssembleData(char field1[], char field2[], char field3[]) |
Re: Something Loopy in Assigning Strings
That's just silly. Disk operations are orders of magnitude slower than memory operations. Use strcat or strncat. They work. If you can't get them to work, show THAT code not this grossly over-footprint, underperforming stuff.
|
Re: Something Loopy in Assigning Strings
I explained in the first message that I tried strcat() and that it doesn't work, either. Here's the code. As usual, I can get "10" but not "11".
Code:
void AssembleData(char field1[], char field2[], char field3[]) |
Re: Something Loopy in Assigning Strings
Found it! Here's the problem. This is what I was doing, essentially:
Code:
#define HI_THERE "hi "Code:
data = strcat("hi ", "idiot");Code:
char data[80] = HI_THERE; |
Re: Something Loopy in Assigning Strings
Actually, the second string can be a literal. There MUST be enough storage in the destination string to accomodate the original plus the second string (literal or otherwise).
|
| All times are GMT +5.5. The time now is 09:25. |