Re: There is really important wrong, but I couldnt find
- From: Martin Ambuhl <mambuhl@xxxxxxxxxxxxx>
- Date: Fri, 30 Nov 2007 16:21:20 -0500
emre esirik(hacettepe computer science and engineering) wrote:
struct guitar active;^^^^^^^^^^^^
char *buffer_char3;
while(!feof(ptdata))
This is almost certainly _not_ what you want. Why is this Pascalism so common? It can't be that any competent C textbook actually suggests it.
{
fgets(buffer[0],26, ptdata);
fgets(buffer[1],26, ptdata);
fgets(buffer[2],26, ptdata);
fgets(buffer[3],26, ptdata);
fgets(buffer[4],26, ptdata);
Each of the above should be checked for success.
You don't show a declaration of buffer, so I assume it is an array of char arrays, each of adequate length. Check to make sure.
active.serial=integer_analys(buffer[0]);
active.price=integer_analys(buffer[1]);
buffer_char = strtok (buffer[2], bracket);
buffer_char = strtok (NULL, bracket);
buffer_char2 = strtok (buffer[3], bracket);
buffer_char2 = strtok (NULL, bracket);
buffer_char3 = strtok (buffer[4], bracket);
buffer_char3 = strtok (NULL, bracket);
It is rarely right to use strtok on your only copy of a string, since it is destructive. Note that an array of
char *buffer_char[5];
would parallel the (assumed) declaration of
#define BIGENOUGH 27
char buffer[5][BIGENOUGH];
and allow the use of loops for processing.
Also note that you have destroyed the first values returned by strtok assigned to the buffer_char* by the second calls.
how can I convert buffer_char3 to active.model ( model is char
array of guitar struct component)
buffer_char3 points to a string. You want to store it in a char array. Doesn't the extremely obvious copy using any of the strcpy, strncpy, memcpy, or memmove function work for you.
I have tried to find for 4 days, I did everything but I couldnt
help me please
I suspect that you are confused about _what_ you are trying to do. Get that straight before even thinking about _how_ to do it.
.
- References:
- There is really important wrong, but I couldnt find
- From: emre esirik(hacettepe computer science and engineering)
- There is really important wrong, but I couldnt find
- Prev by Date: Win32: C: Chinese language inputting improperly in text box. Extremely strange bug, please help!
- Next by Date: Re: Global Variables : Where are they stored ?
- Previous by thread: There is really important wrong, but I couldnt find
- Next by thread: Win32: C: Chinese language inputting improperly in text box. Extremely strange bug, please help!
- Index(es):
Relevant Pages
|