Hello all,
I am taking a line of text (lineOfText) and trying to insert and email address at a specific location (locationFound). I make a copy of the line of text, add the email address and copy the remaininder of the string from the copy. when I run this, it prints the lineOfText up to where I inserted the email address and then stops....
Code:
void createNewGorseveRecord(char lineOfText[], int locationFound)
{
int i;
int fieldLength=0;
int startPos=locationFound;
int lineLength=0;
char *emailaddr = [email protected];
char copyLine[LINESIZE];
fieldLength = strlen(emailaddr);
lineLength = strlen(lineOfText);
printf("NEW LINE: %s \n",lineOfText);
strcpy(copyLine, lineOfText);
for (i=0;i<=fieldLength;i++)
{
lineOfText[locationFound] = emailaddr[i];
locationFound++;
}
for (i=startPos;i<lineLength;i++)
{
printf("< %d %c \n",i,copyLine[i]);
lineOfText[locationFound] = copyLine[i];
printf("> %d %c \n",locationFound, lineOfText[locationFound]);
locationFound++;
}
printf("NEW LINE: %s \n",lineOfText);
When I print out each character I am copying from and too, it shows the correct character, then when my last line prints the lineOfText, it truncates to where I enter the new string, is this a buffer size problem?