Iv been programming in C++ for about two years. I was taught using borland 5.5, so maybe iv been spared some of the perils of C programming.
Recently iv been trying to write opensource programs (eventually for linux), i was writing a test harness when i hit upon this problem.
I try to concatenate two strings and the program crash's.
heres the code :
----------------------------------------------------------------------------------------------
{
char disk, partition[4], fileSys[10];
char *command = "mount ";
cout << "\nPlease enter the location of the disk on the IDE cable( 0 - 3 ) >>";
cin >> disk;
cout << "\nEnter partition number (1 - 100) >>";
cin >> partition;
cout << "\nEnter the file System >>";
cin >> fileSys;
switch (int (disk))
{
case '0' : disk = 'a';
break;
case '1' : disk = 'b';
break;
case '2' : disk = 'c';
break;
case '3' : disk = 'd';
break;
default : cout << "Invalid position";
break;
}
strcat(command, fileSys);
cout << "Final Command : " << command;
}
-----------------------------------------------------------------------------------------------
I have tried with both the old string.h header and the newer cstring and it still crashes w/o explaination.
Im using the dev-C++ IDE and i think it uses the mingW compiler, iv tried both the stable and new beta and still it crashes out. I can use the command line borland compiler, but i hate using it due to it being slow and trouble some when you have long path names.
Anyone got any ideas?
Dave