To everyone out there,

I have this program in mind that manipulates a string keyed in by a user. Here's what the program is supposed to do…

I am to enter a string into an array and then manipulate this string by..
a) Deleting any word or character in that string
b) Insert any word or character anywhere in the string I previously entered (while displaying its position in the string)
c) Search any word or character present in the string that was previously entered

Its sample run goes like this...

Enter source string: Internet use is growing rapidly.
(it goes into this array that I've declared <I put this array in imaginary boxes to illustrate the idea, including the spaces>)

|I|n|t|e|r|n|e|t| |u|s|e| |i|s| |g|r|o|w|i|n|g| |r|a|p|i|d|l|y|.|\0|

(Then a menu appears below it...)
Choose from the Menu
D <Delete>
I <Insert>
F <Find>
Q <Quit>
choice: _


(When the user keys in a preferred action, this is what each choice is supposed to do...)
(if F <Find>)
String to search: .
" . " found at position 23
(what happens to the array->)
|I|n|t|e|r|n|e|t| |u|s|e| |i|s| |g|r|o|w|i|n|g| |r|a|p|i|d|l|y|.|\0|
string to search: - |.|
at what position: 23
display >> "." found at position 23


(if F <Find>)
String to search: use
"use" found at position 9
(what happens to the array->)
|I|n|t|e|r|n|e|t| |u|s|e| |i|s| |r|a|p|i|d|l|y| |e|x|p|a|n|d|i|n|g|.|\0|
string to search: - | |u|s|e| |
at what position: 9
display >> "use" found at position 9


(if I <Insert>)
String to insert: expanding
Position of insertion: 23
New string: Internet use is rapidly expanding.
(what happens to the array->) |I|n|t|e|r|n|e|t| |u|s|e| |i|s| |r|a|p|i|d|l|y|.|\0|
string to insert: -| |e|x|p|a|n|d|i|n|g| |
at what position: 23
new string:-
|I|n|t|e|r|n|e|t| |u|s|e| |i|s| |r|a|p|i|d|l|y| |e|x|p|a|n|d|i|n|g|.|\0|


(if D <Delete>)
String to delete: growing
New string: Internet use is rapidly.
(what happens to the array->)
|I|n|t|e|r|n|e|t| |u|s|e| |i|s| |g|r|o|w|i|n|g| |r|a|p|i|d|l|y|.|\0|
string to delete: -| |g|r|o|w|i|n|g| |
new string:-
|I|n|t|e|r|n|e|t| |u|s|e| |i|s| |r|a|p|i|d|l|y|.|\0|


I made up the steps for some of the menu functions in English (along with a C source line) but I'm not sure if these are correct…

I) Search any word or character present in the string that was previously entered (Find function)
- get string to search <
Code:
gets (search_str)
>
- from the beginning of the main string, until it is not the end of the main string, increment forward
<
Code:
(i =0; i < main_str [80]; i++)
>
a) compare lengths of the string to search and the main string
<
Code:
if ((strcmp (searchstr, main_str)) == 0)
      found = 1;
>
If match is found <
Code:
 if (found)
>
a) Note position of the first letter of the word or the single character then display it and the word or character to the screen.
<
Code:
printf (" \" %s \" found at position %d", searchstr, main_str[i] );
>
Else
a) say that a the string to search does not exist.
<
Code:
printf ("The word you want to search does not exist");
>


II) Delete any word or character present in the string that was previously entered (Delete function)
- get string to delete <
Code:
gets (del_str)
>
- from the beginning of the main string, until it is not the end of the main string, increment forward
<
Code:
(i =0; i < main_str [80]; i++)
>
a) compare lengths of the string to delete and the main string
<
Code:
if ((strcmp (searchstr, main_str)) == 0)
      found = 1;
>
if match is found < if (found) >
a)Turn each character of the main string that matches the character of the substring into a
space
<
Code:
 *strptr [ i - 1] = ' ';
>
b)Transfer each element of the main string array into a new array of the same size named, newstring.
<
Code:
strcpy (main_str, newstring);
>
c)Display the contents of the array containing the modified main string to the screen
<
Code:
printf ("New string: %s", newstring);
>
else
a) say that the string to delete does not exist.
<
Code:
printf ("The word you want to delete does not exist");
>


I can't think of a way to get the Insert function - I'm stumped for ideas on it , I'd be so dead grateful if you have any.

I'd welcome any suggestions for my post above (if you can provide some C source lines, please do).


Respectfully yours,
the_newbug