| | |
left operand must be l-value
Thread Solved |
what's wrong here?
c Syntax (Toggle Plain Text)
typedef struct person { int age; char name[50]; }; int main() { struct person test; test.age = 20; test.name = "Test"; return 0; }
Do a favour, leave me alone
0
#2 20 Days Ago
anyways i fixed it myself
here is the solution
here is the solution c Syntax (Toggle Plain Text)
typedef struct { int age; char *name[50]; } Person; Person newperson(char *name, int age) { Person temp; *temp.name = name; temp.age = age; return temp; } int main() { Person list[50], ttt; list[0] = newperson("Test", 20); *ttt.name = "ASDF"; return 0; }
Do a favour, leave me alone
0
#3 20 Days Ago
Use strcpy to copy a string. You've got more going wrong in that code, though. I think you're after something that might look a bit like this:
C Syntax (Toggle Plain Text)
#include <string.h> typedef struct { int age; char name[50]; } Person; Person newperson(char *name, int age) { Person temp; strcpy(temp.name, name); temp.age = age; return temp; }
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- compiler won't accept char as xor operand (C++)
- error c2296: '/': "left hand"; :c2297: "right hand" illegal.... (C++)
- '=' : left operand must be l-value (C++)
- AHHHH!! i cant figure this out. (C++)
- '%' illegal, left operand, has type 'double' (C++)
- Pythagorean Triples (C)
Other Threads in the C Forum
- Previous Thread: raw sockets using mac addresses
- Next Thread: How to produce an assembly file (.asm) on Windows by program in C
| Thread Tools | Search this Thread |
#include * ansi api array arrays asterisks binarysearch calculate centimeter changingto char character convert copyanyfile copyimagefile copypdffile creafecopyofanytypeoffileinc createcopyoffile createprocess() database dynamic execv fflush fgets file floatingpointvalidation fork forloop frequency function getlogicaldrivestrin givemetehcodez grade graphics gtkwinlinux histogram homework i/o inches include infiniteloop input interest intmain() iso keyboard km license linked linkedlist linux list looping loopinsideloop. lowest matrix microsoft mysql oddnumber open opendocumentformat openwebfoundation pdf pointer posix power program programming pyramidusingturboccodes radix read recursion recv recvblocked reversing scanf scheduling segmentationfault send sequential shape single socket socketprogramming stack standard strchr string suggestions test threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi






