Hey guys,
I am trying to get a grasp on using the '->' notation which I think, I slowly do understand. However, in the CheckString function, where I am trying to assign three different things to different pointers, I get errors. The file has a 3 digit number, a boat name (can consist of more than one name - not the name of the class though) not longer than 30 chars long, and a boat type which is represented as a string but given as a enum in the header.
The errors I had are as follows:line 27 is my main line. and the rest is the actual CheckString function.Code:regatta.c:27: two or more data types in declaration of `main' regatta.c:27: function definition declared `typedef' regatta.c: In function `CheckString': regatta.c:105: parse error before `Participants' regatta.c:107: parse error before `int' regatta.c:107: `i' undeclared (first use in this function) regatta.c:107: (Each undeclared identifier is reported only once regatta.c:107: for each function it appears in.) regatta.c:107: parse error before `)' regatta.c:115: parse error before `strcpy' regatta.c:125: warning: passing arg 1 of `strcpy' makes pointer from integer wit hout a cast regatta.c:125: warning: passing arg 2 of `strcpy' makes pointer from integer wit hout a cast regatta.c: At top level: regatta.c:129: parse error before `->'
Sorry if its getting too long. I just wanted to keep it as simple as possible. Thanks for your help in advance. Appreciate any kind of help.Code:char * CheckString( char *ptrdata ) { Boat *boatptr; BoatType *Typeptr; /*temporary variables for read strings*/ char *ptrSail, *ptrClassType, *ptrBoatName; boatptr = Participants[ 0 ]; for( int i = 0; i < 80; ++i ) { if( isdigit( ptrdata[ i ] ) != 0 ) strcpy( ptrSail[ i ], ptrdata[ i ] ); if( isalpha( ptrdata[ i ] ) != 0 ) { if( strstr( ptrdata, "Gwen" ) strcpy( *ptrClassType, *ptrdata ); /*if boat type is Thorpe copy what follows from that point onwards*/ else if( strstr( *ptrdata, "Thorpe" ) strcpy( *ptrClassType, *ptrdata ); /*if boat type is Skiff copy what follows from that point onwards*/ else if( strstr( *ptrdata, "Skiff" ) strcpy( *ptrClassType, *ptrdata ); /*else it is the boat name so copy to pointer*/ strcpy( *ptrBoatName, *ptrdata ); } } boatptr->SailNum = ptrSail; boatptr->BoatName = ptrBoatName; }
Ta,
Johannes



LinkBack URL
About LinkBacks


