Friday, February 11, 2011
Thursday, February 10, 2011
Source code to insert string into another string
main ( )
{
char string[100], insert[100], newstring[200] = {' '};
char *stringpointer = string, *insertpointer = insert, *newstringpointer = newstring;
int position, charcount = 0 ;
cout << "enter first string:"<< endl;
gets(string);
cout << "enter second string "<< endl;
gets(insert);
cout << "Enter Poition to Inserrt:";
cin >> position;
while(*stringpointer != '\0')
{
if(charcount == position)
{
while (*insertpointer != '\0')
{
*newstringpointer++ = *insertpointer++;
++charcount;
}
}
*newstringpointer++ = *stringpointer++ ;
++charcount;
}
cout << "result"<<endl;
cout << newstring ;
}
Tuesday, February 8, 2011
Subscribe to:
Posts (Atom)