While I couldn't get this homework to work yesterday, I was working on this one.
Code:
void insertString(char string[], char c[], int idx)
{
//long int len = strlen(string);
char stringtwo[2000] = "";
int i;
i = 0;
while ((string[i] = c[i]) != '\0') {
i++;
strcpy(stringtwo,string);
strcpy(stringtwo,c);
}
printf("%s", stringtwo);
}
int main()
{
char text[ 200 ] = "Doubt I love.";
insertString(text, "thou the stars are fire;\n Doubt that ", 5);
insertString(text, "the sun doth move;\n Doubt ", 42);
insertString(text, "truth to be a liar;\n But never doubt ", 68);
printf(" %s\n", text );
}
This is what it prints
Code:
thou the stars are fire;
Doubt that the sun doth move;
Doubt truth to be a liar;
But never doubt truth to be a liar;
But never doubt
This is what it's supposed to print.
Code:
{Doubt }thou the stars are fire;
Doubt that the sun doth move;
Doubt truth to be a liar;
But never doubt {I love.}