Answer the question
In order to leave comments, you need to log in
How to insert a new word between the first and second word in an arbitrary text?
Can't write program
Answer the question
In order to leave comments, you need to log in
Text is a list of words. Therefore, the task is reduced to inserting a word into a list.
Damn, is there a group of students dug in, which now has the topic "working with text"?
man realloc, dude,
either read the text, calculate how much it has increased, take memory for the new version, copy the word, insert a new word, insert the tail.
well, either "Freelance"
Not surprising. The "C" language is generally poorly suited for text processing. The semantics of ASCIIZ-vectors is such that in order to insert "something" somewhere, you need to: Measure the size of the string. Measure the size of the inserted string. Allocate memory. Copy the old line to the new location with changes.
Modify a string in place... hmm.. not a good idea. I wouldn't advise. Makes code potentially dangerous. All the same it is better that the line was immutable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question