//exit on failure of memory allocation
if(!ptrCar || !ptrNumber || !ptrDestination)
{
fprintf(stderr, "Could not allocate memory!\n");
exit(1);
}
//get information and copy to structure
printf("CAR NUMBER: ");
gets(buffer);
strcpy(ptrNumber, buffer);
ptrCar->number = ptrNumber;
printf("WHAT TYPE?\n\t1)BOX\n\t2)TANK\n\t3)FLAT\n");
scanf("%d", &numBuffer);
//------------------------------------------------------------------
ptrCar->type = numBuffer; //here's the line with the problem
//------------------------------------------------------------------
printf("IS IT LOADED(y/n)? ");
scanf("%d", &numBuffer);
ptrCar->loaded = numBuffer;
error C2440: '=' : cannot convert from 'int' to 'RECORD::Type'
Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
I've tried:
ptrCar->type = (int) numBuffer;
ptrCar->type = int (numBuffer);
but it didn't work, and we haven't been taught about static_cast yet. Any ideas? Thanks
worked perfectly thanks. Stylistically does any one have problems with what I wrote and why? Our hmwk was to code the problem in C and only change the structure to a class.