View Single Post
Old 04-15-2004, 04:49 AM   #6 (permalink)
Engineer
Registered User
 
Join Date: Feb 2003
Location: cold
Posts: 5
Engineer is on a distinguished road
Sorry I didn't want you guys to think I was asking for my homework to be done for me. This is a beginning class "Intro to Object Oriented Programing." I did a little research on strcat since we've never used it before and here is my code so far, probably not right but it compiles with no errors lol;

Code:
#include <iostream>
using namespace std;

int main()
{
    char string1[] = {"My name is "};
	char string2[] = {"Fred."};
	char string3[50];
	int index;

for(index = 0; string1[index] != 0; ++index)
{
	//value of string1 is now stored in string 3
	string3[index] = string1[index];
}

for(index = 0; string2[index] != 0; ++index)
{
	//attaching  string2 to the end of string3
	strcat(string3, string2);
	cout << string3 << endl;	//pretty sure this is wrong, testing
}

return 0;
}
Engineer is offline   Reply With Quote