If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > struct

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-12-04, 10:20
fj8283888 fj8283888 is offline
Registered User
 
Join Date: Apr 2004
Posts: 38
Exclamation problems with struct

Hi the following is the struct format:
typedef struct iorb {

short base_pri;
struct iorb *link;
char filler[110];

} IORB;

I try to assign a string to base_pri, the code I used as followed
temp->filler=filler3;However it shows the error code like this
" temp->filler=filler3;is not an lvalue, but occurs in a context that requires one. (needlvalue)" So what is the problem with it?


I did declare IORB *temp and char filler3[110];
when I compile, it shows me a message could you please help me to solve this problem.

Thanks,
Frenk

Last edited by fj8283888; 04-12-04 at 11:18.
Reply With Quote
  #2 (permalink)  
Old 04-13-04, 08:03
Apel Apel is offline
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 228
As you know C usually handles strings as char arrays.
The = operator can only be used to assign basic data types like char, integer and float. The -> operator is used to dereference a pointer within a struct ( struct->pointer is equal to *(struct.pointer) ).
You are trying to assign the address of the first element of your filler3 array the value of the first element of the temp.filler array. Depending on what you want to do in your program you either need to assign the pointers, e.g. temp.filler = filler3 or you need to copy all elements of the arrays, e.g. strcpy(temp.filler, filler3).

edit: typo
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On