/** * @Comment: WSU - Fall 06 - CS 3830-0 * @Title: prj2d.c - Project 2d * @Author: Vincenzo Maggio */ #include #include #include #include int Concat( char *pEntree, char *pVeggie, char *pDessert) { int i; char *entree = (char *) malloc( strlen( pEntree)); char *veggie = (char *) malloc( strlen( pVeggie)); char *dessert = (char *) malloc( strlen( pDessert)); char *meal = (char *) malloc( (size_t) 15 ); if ( entree == NULL || veggie == NULL || dessert == NULL || meal == NULL ) { printf("\nError: malloc() failed. Aborting..\n\n"); exit( -1); } memset( meal, '\0', 15); system("cls"); system("color 1e"); gotoxy( 27, 2); puts("--==]~~~ \01 0xYg3N \01 ~~~[==--"); gotoxy( 2, 4); puts("Heap Overflow - Meal is [14+1] long"); gotoxy( 1, 6); puts( "Address 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); gotoxy( 1, 8); printf( "%x ", meal); gotoxy( 9, 8); for ( i=0; i<16; i++) printf( "%2x ", *(meal+i)); gotoxy( 62, 8); for ( i=0; i<16; i++) printf( "%c", *(meal+i)); strcat( meal, entree); strcat( meal, " + "); strcat( meal, veggie); strcat( meal, " + "); strcat( meal, dessert); gotoxy( 1, 10); printf( "%x ", meal); gotoxy( 10, 10); for ( i=0; i<16; i++) printf( "%2x ", *(meal+i)); gotoxy( 64, 10); for ( i=0; i<16; i++) printf( "%c", *(meal+i)); printf("\n\n "); system("color 0f"); printf("\n\n Thanks for using Prj2d!\n\n"); return 0; } int main( int argc, char *argv[]) { if ( argc != 4 ) { printf("\nError: wrong arguments count."); exit( 1); } Concat( argv[1], argv[2], argv[3] ); return 0; }