| | |
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 23 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 23 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 * adobe ansi api array asterisks binarysearch centimeter changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc csyntax database directory dynamic execv feet fgets file fork function getlasterror getlogicaldrivestrin givemetehcodez global grade gtkgcurlcompiling gtkwinlinux hacking hardware highest histogram ide include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue number odf opendocumentformat opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing segmentationfault sequential single socket socketprograming standard string systemcall threads turboc unix user voidmain() wab whythiscodecausesegmentationfault windows.h windowsapi






