I am trying to edit a string in c. I need to remove the last 84 characters from a string[400], insert text and re-insert the 84 character string at the end.

No problem adding text or coping text in C, but I can't remember how to reorder/manipulate the text string.

Just need my memory jogged.
Thanks for any help.

Recommended Answers

All 3 Replies

I am trying to edit a string in c. I need to remove the last 84 characters from a string[400], insert text and re-insert the 84 character string at the end.

No problem adding text or coping text in C, but I can't remember how to reorder/manipulate the text string.

Just need my memory jogged.
Thanks for any help.

Do you mean like:
string[400];
string[400-84] = '\0';
strcat( string, "<new_string>" );

or maybe:
string[ strlen( string ) - 84 ] = '\0';
strcat( string, "<new_string>" );

I do, thank you. Was having a daft moment!

but you needed to re-insert the 84 char string again into the new string..rt?

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.