is there any function to add a character at the end of a string? or algorithm?
Thundermax 0 Light Poster
Recommended Answers
Jump to PostIs the array holding the string large enough for another character? Because if so it's a simple matter of:
s[size] = c; // Overwite the nul with a new character s[++size] = '\0'; // Terminate the string after the new character
Jump to PostPlease post actual C code that you want to add this feature to. If you're working with a pointer to a string literal then you can't modify it.
Jump to PostHard to tell without seeing the code you wrote. A couple possibilities: 1. the string was not null terminated, 2. buffer overrun (writing beyond the bounds of the buffer)
Jump to PostCurious: why didn't you use standard C string function strcpy() instead of your chop()?
lines 70 and 71: increase the size of those two because they probably aren't big enough.
Jump to Postit took the space " " that exists in the last row
Huh? The function does nothing if there is no '\n' in the string. If you want a space there then modify the function to append a space if there is no '\n'.
All 37 Replies
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Thundermax 0 Light Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Thundermax 0 Light Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Thundermax 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.