|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Virtual Tradeshows by Ziff Davis Enterprise - A Unique Opportunity to Connect with IT Experts, Access Information, and Gain Insight on today's Technology
|
|
#1
|
|||
|
|||
|
/*Hey all.....I have a little problem.*/
/*I create a string and initialise it*/ char longstring[250]; strcpy(longstring, "host-"); /*I also have another string query[500] and later in the code I initialise that.....then I add to it using strcat*/ /*THEN, for some mystical reason.....longstring[250] has, ummm.....dissapeared.....(longstring == "").....funny, huh? especially seeing as it isn't mentioned in the code AT ALL inbetween the points when it's there and when it's not*/ /*one other thing I noticed is that while all this is going through a loop, after a while, (longstring == 0), then after another while, (longstring == 00)......???????*/ anyone have any idea what's going on?????? thanks, Des. |
|
#2
|
|||
|
|||
|
ok, I figured it out........
char buffer[5], char longstring[250]; buffer was being past a string representation of integers in most cases.....but in one it was being passed a double (from sprintf).....[5] was not big enough to hold , say, 100.000000 ......so it was passing the last few digits into the next string, longstring....which is why it was printing 0, then 00......etc. thanks anyways |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > string dissapearing problem using strcpy and strcat |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|