Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/21/04 20:54
Read: times


 
#74646 - RE: doub about strutc pointers
Responding to: ???'s previous message
For the most part your code looks OK, but I do see a couple of problems. The first is the line:

auxBuf=par->str;

This won't work; that's trying to change the address of auxBuf, and the compiler won't let you do that. If you reversed it (par->str=auxBuf) that would work, but perhaps not be what you're trying to do. It would be OK if auxBuf had been declared

char *auxBuf;

but then you've got to allocate storage for the buffer itself *someplace*.

[Thinking some more...] Or perhaps you meant to copy the string from par->str to auxBuf, in which case strcpy(auxBuf, par->str) could be used--or better yet strncpy(auxBuf, par->str, 30) so you can guard against buffer overflow.

The other thing I see is probably a typo:

par->INPS->fTake=20;

I'm sure you meant "=" (assign) not "==" (logical equal).

Sometimes when I'm in doubt about some code I let my compiler have a go at it to see what it complains about, then look at the generated code or simulate it to verify it's doing what I want to.

Dennis


List of 19 messages in thread
TopicAuthorDate
doub about strutc pointers            01/01/70 00:00      
   RE: doub about strutc pointers            01/01/70 00:00      
   RE: doub about strutc pointers            01/01/70 00:00      
      What do you doubt?            01/01/70 00:00      
         RE: What do you doubt?            01/01/70 00:00      
            RE: What do you doubt?            01/01/70 00:00      
            RE: What do you doubt?            01/01/70 00:00      
               RE: What do you doubt?            01/01/70 00:00      
                  RE: What do you doubt?            01/01/70 00:00      
                  RE: What do you doubt?            01/01/70 00:00      
                     RE: What do you doubt?            01/01/70 00:00      
            RE: undefined behaviour land            01/01/70 00:00      
         RE: What do you doubt?            01/01/70 00:00      
         Still unknown doubt            01/01/70 00:00      
   RE: doub about strutc pointers            01/01/70 00:00      
      Nothing 8051-specific here            01/01/70 00:00      
         RE: Nothing 8051-specific here            01/01/70 00:00      
   RE: doub about strutc pointers            01/01/70 00:00      
   RE: doub about strutc pointers            01/01/70 00:00      

Back to Subject List