error: expected ';', ',' or ')' before '.' token? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!What does this error mean: “error: expected specifier-qualifier-list before 'type_name'”?expected ')' before '*' token with function pointer“expected specifier-qualifier-list before ‘*’ token” error in variadic functionFunction not working unless called in same fileerror: expected ‘;’, ‘,’ or ‘)’ before ‘.’ tokenerror: expected expression before '' token’ or ‘__attribute__’ before ‘=’ token
Israeli soda type drink
Split coins into combinations of different denominations
Second order approximation of the loss function (Deep learning book, 7.33)
Additive group of local rings
Is Diceware more secure than a long passphrase?
c++ diamond problem - How to call base method only once
How to keep bees out of canned beverages?
The art of proof summarizing. Are there known rules, or is it a purely common sense matter?
"My boss was furious with me and I have been fired" vs. "My boss was furious with me and I was fired"
Does the set of sets which are elements of every set exist?
"Rubric" as meaning "signature" or "personal mark" -- is this accepted usage?
I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?
What *exactly* is electrical current, voltage, and resistance?
std::is_constructible on incomplete types
Identify story/novel: Tribe on colonized planet, not aware of this. "Taboo," altitude sickness, robot guardian (60s? Young Adult?)
Do I need to protect SFP ports and optics from dust/contaminants? If so, how?
Arriving in Atlanta after US Preclearance in Dublin. Will I go through TSA security in Atlanta to transfer to a connecting flight?
Map material from china not allowed to leave the country
How long after the last departure shall the airport stay open for an emergency return?
What if Force was not Mass times Acceleration?
As an international instructor, should I openly talk about my accent?
What is the term for a person whose job is to place products on shelves in stores?
Co-worker works way more than he should
What was Apollo 13's "Little Jolt" after MECO?
error: expected ';', ',' or ')' before '.' token?
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!What does this error mean: “error: expected specifier-qualifier-list before 'type_name'”?expected ')' before '*' token with function pointer“expected specifier-qualifier-list before ‘*’ token” error in variadic functionFunction not working unless called in same fileerror: expected ‘;’, ‘,’ or ‘)’ before ‘.’ tokenerror: expected expression before '' token’ or ‘__attribute__’ before ‘=’ token
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm writing a program in C with structs and pointers etc.
However, when I run it, it gives this error: "error: expected ';', ',' or ')' before '.' token"
at the following line
char *strcpy(char *account[i].nome, const char *nomi[p]);
Basically what I wanna do is, assing a random name taken from char nomi[p] where p is a random index between 0 and 4 into account.nome[i] variable where [i] is decleared in the for loop.
As you can see I commented this line
//account[i].nome = nomi[p];
Otherwise it would have gave me this error -> error: assignment to expression with array type
Any hints?
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h> // includo la libreria per gestire le funzioni sui caratteri
#define MAX_ACCOUNT 5
#define MAX_NOME 20
#define MAX_COGNOME 20
#define MAX_EMAIL 40
typedef struct
int giorno;
int mese;
int anno;
data;
typedef struct
char nome[MAX_NOME];
char cognome[MAX_COGNOME];
data datadinascita;
char email[MAX_EMAIL];
char password;
acc;
int main(void)
int seed = time(NULL); // Randomizzo
srand(seed); // time
unsigned i = 0;
unsigned p = 0;
unsigned q = 0;
unsigned r = 0;
char* nomi[4] = "Gianmarco","Francesco","Michele","Marco","Roberto";
char* cognomi[4] = "Lorusso","Simone","Caggiano","Moramarco","Colonna";
char* email[4] = "rymmysice-2084@gmail.com","junetome-4060@hotmail.com","ikijaza-9272@live.it","hokalife-2155@libero.it","ottejotto-2395@gmail.com";
acc account[MAX_ACCOUNT] = 0;
data datadinascita[MAX_ACCOUNT]; //variabile datadinascita
//Ciclo di lettura
for(i = 0; i < MAX_ACCOUNT; i++)
p = rand() % (4-0+1) + 0; //Max 4, Min 0
q = rand() % (4-0+1) + 0; //Max 4, Min 0
r = rand() % (4-0+1) + 0; //Max 4, Min 0
char *strcpy(char *account[i].nome, const char *nomi[p]);
//account[i].nome = nomi[p];
//account[i].cognome = *cognomi[q];
datadinascita[i].giorno = rand() % (31-1+1) + 1; //Max 31, Min 1
datadinascita[i].mese = rand() % (12-1+1) + 1; //Max 12, Min 1
datadinascita[i].anno = rand() % (2003-1960+1) + 1960; //Max 2003, Min 1960
//account[i].email = *email[r];
printf("ACCOUNT #%d: ", i+1);
printf("Prova");
printf("ntNome: %19s", account[i].nome);
printf("ntCognome: %19s", account[i].cognome);
printf("ntData di nascita: %d-%d-%d", datadinascita[i].giorno, datadinascita[i].mese, datadinascita[i].anno);
printf("ntEmail: %39s", account[i].email);
printf("n");
return 0;
c pointers struct
add a comment |
I'm writing a program in C with structs and pointers etc.
However, when I run it, it gives this error: "error: expected ';', ',' or ')' before '.' token"
at the following line
char *strcpy(char *account[i].nome, const char *nomi[p]);
Basically what I wanna do is, assing a random name taken from char nomi[p] where p is a random index between 0 and 4 into account.nome[i] variable where [i] is decleared in the for loop.
As you can see I commented this line
//account[i].nome = nomi[p];
Otherwise it would have gave me this error -> error: assignment to expression with array type
Any hints?
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h> // includo la libreria per gestire le funzioni sui caratteri
#define MAX_ACCOUNT 5
#define MAX_NOME 20
#define MAX_COGNOME 20
#define MAX_EMAIL 40
typedef struct
int giorno;
int mese;
int anno;
data;
typedef struct
char nome[MAX_NOME];
char cognome[MAX_COGNOME];
data datadinascita;
char email[MAX_EMAIL];
char password;
acc;
int main(void)
int seed = time(NULL); // Randomizzo
srand(seed); // time
unsigned i = 0;
unsigned p = 0;
unsigned q = 0;
unsigned r = 0;
char* nomi[4] = "Gianmarco","Francesco","Michele","Marco","Roberto";
char* cognomi[4] = "Lorusso","Simone","Caggiano","Moramarco","Colonna";
char* email[4] = "rymmysice-2084@gmail.com","junetome-4060@hotmail.com","ikijaza-9272@live.it","hokalife-2155@libero.it","ottejotto-2395@gmail.com";
acc account[MAX_ACCOUNT] = 0;
data datadinascita[MAX_ACCOUNT]; //variabile datadinascita
//Ciclo di lettura
for(i = 0; i < MAX_ACCOUNT; i++)
p = rand() % (4-0+1) + 0; //Max 4, Min 0
q = rand() % (4-0+1) + 0; //Max 4, Min 0
r = rand() % (4-0+1) + 0; //Max 4, Min 0
char *strcpy(char *account[i].nome, const char *nomi[p]);
//account[i].nome = nomi[p];
//account[i].cognome = *cognomi[q];
datadinascita[i].giorno = rand() % (31-1+1) + 1; //Max 31, Min 1
datadinascita[i].mese = rand() % (12-1+1) + 1; //Max 12, Min 1
datadinascita[i].anno = rand() % (2003-1960+1) + 1960; //Max 2003, Min 1960
//account[i].email = *email[r];
printf("ACCOUNT #%d: ", i+1);
printf("Prova");
printf("ntNome: %19s", account[i].nome);
printf("ntCognome: %19s", account[i].cognome);
printf("ntData di nascita: %d-%d-%d", datadinascita[i].giorno, datadinascita[i].mese, datadinascita[i].anno);
printf("ntEmail: %39s", account[i].email);
printf("n");
return 0;
c pointers struct
5
char *strcpy(char *account[i].nome, const char *nomi[p]);is not a function call.
– Eugene Sh.
Mar 22 at 15:51
1
Changechar *strcpy(char *account[i].nome, const char *nomi[p]);tostrcpy(account[i].nome, nomi[p]);and add#include <stdlib.h>and#include <time.h>. You are also trying to provide 5 initialisers to your 4-element arrays.
– Weather Vane
Mar 22 at 15:56
add a comment |
I'm writing a program in C with structs and pointers etc.
However, when I run it, it gives this error: "error: expected ';', ',' or ')' before '.' token"
at the following line
char *strcpy(char *account[i].nome, const char *nomi[p]);
Basically what I wanna do is, assing a random name taken from char nomi[p] where p is a random index between 0 and 4 into account.nome[i] variable where [i] is decleared in the for loop.
As you can see I commented this line
//account[i].nome = nomi[p];
Otherwise it would have gave me this error -> error: assignment to expression with array type
Any hints?
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h> // includo la libreria per gestire le funzioni sui caratteri
#define MAX_ACCOUNT 5
#define MAX_NOME 20
#define MAX_COGNOME 20
#define MAX_EMAIL 40
typedef struct
int giorno;
int mese;
int anno;
data;
typedef struct
char nome[MAX_NOME];
char cognome[MAX_COGNOME];
data datadinascita;
char email[MAX_EMAIL];
char password;
acc;
int main(void)
int seed = time(NULL); // Randomizzo
srand(seed); // time
unsigned i = 0;
unsigned p = 0;
unsigned q = 0;
unsigned r = 0;
char* nomi[4] = "Gianmarco","Francesco","Michele","Marco","Roberto";
char* cognomi[4] = "Lorusso","Simone","Caggiano","Moramarco","Colonna";
char* email[4] = "rymmysice-2084@gmail.com","junetome-4060@hotmail.com","ikijaza-9272@live.it","hokalife-2155@libero.it","ottejotto-2395@gmail.com";
acc account[MAX_ACCOUNT] = 0;
data datadinascita[MAX_ACCOUNT]; //variabile datadinascita
//Ciclo di lettura
for(i = 0; i < MAX_ACCOUNT; i++)
p = rand() % (4-0+1) + 0; //Max 4, Min 0
q = rand() % (4-0+1) + 0; //Max 4, Min 0
r = rand() % (4-0+1) + 0; //Max 4, Min 0
char *strcpy(char *account[i].nome, const char *nomi[p]);
//account[i].nome = nomi[p];
//account[i].cognome = *cognomi[q];
datadinascita[i].giorno = rand() % (31-1+1) + 1; //Max 31, Min 1
datadinascita[i].mese = rand() % (12-1+1) + 1; //Max 12, Min 1
datadinascita[i].anno = rand() % (2003-1960+1) + 1960; //Max 2003, Min 1960
//account[i].email = *email[r];
printf("ACCOUNT #%d: ", i+1);
printf("Prova");
printf("ntNome: %19s", account[i].nome);
printf("ntCognome: %19s", account[i].cognome);
printf("ntData di nascita: %d-%d-%d", datadinascita[i].giorno, datadinascita[i].mese, datadinascita[i].anno);
printf("ntEmail: %39s", account[i].email);
printf("n");
return 0;
c pointers struct
I'm writing a program in C with structs and pointers etc.
However, when I run it, it gives this error: "error: expected ';', ',' or ')' before '.' token"
at the following line
char *strcpy(char *account[i].nome, const char *nomi[p]);
Basically what I wanna do is, assing a random name taken from char nomi[p] where p is a random index between 0 and 4 into account.nome[i] variable where [i] is decleared in the for loop.
As you can see I commented this line
//account[i].nome = nomi[p];
Otherwise it would have gave me this error -> error: assignment to expression with array type
Any hints?
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h> // includo la libreria per gestire le funzioni sui caratteri
#define MAX_ACCOUNT 5
#define MAX_NOME 20
#define MAX_COGNOME 20
#define MAX_EMAIL 40
typedef struct
int giorno;
int mese;
int anno;
data;
typedef struct
char nome[MAX_NOME];
char cognome[MAX_COGNOME];
data datadinascita;
char email[MAX_EMAIL];
char password;
acc;
int main(void)
int seed = time(NULL); // Randomizzo
srand(seed); // time
unsigned i = 0;
unsigned p = 0;
unsigned q = 0;
unsigned r = 0;
char* nomi[4] = "Gianmarco","Francesco","Michele","Marco","Roberto";
char* cognomi[4] = "Lorusso","Simone","Caggiano","Moramarco","Colonna";
char* email[4] = "rymmysice-2084@gmail.com","junetome-4060@hotmail.com","ikijaza-9272@live.it","hokalife-2155@libero.it","ottejotto-2395@gmail.com";
acc account[MAX_ACCOUNT] = 0;
data datadinascita[MAX_ACCOUNT]; //variabile datadinascita
//Ciclo di lettura
for(i = 0; i < MAX_ACCOUNT; i++)
p = rand() % (4-0+1) + 0; //Max 4, Min 0
q = rand() % (4-0+1) + 0; //Max 4, Min 0
r = rand() % (4-0+1) + 0; //Max 4, Min 0
char *strcpy(char *account[i].nome, const char *nomi[p]);
//account[i].nome = nomi[p];
//account[i].cognome = *cognomi[q];
datadinascita[i].giorno = rand() % (31-1+1) + 1; //Max 31, Min 1
datadinascita[i].mese = rand() % (12-1+1) + 1; //Max 12, Min 1
datadinascita[i].anno = rand() % (2003-1960+1) + 1960; //Max 2003, Min 1960
//account[i].email = *email[r];
printf("ACCOUNT #%d: ", i+1);
printf("Prova");
printf("ntNome: %19s", account[i].nome);
printf("ntCognome: %19s", account[i].cognome);
printf("ntData di nascita: %d-%d-%d", datadinascita[i].giorno, datadinascita[i].mese, datadinascita[i].anno);
printf("ntEmail: %39s", account[i].email);
printf("n");
return 0;
c pointers struct
c pointers struct
edited Mar 22 at 15:52
Some programmer dude
306k25266429
306k25266429
asked Mar 22 at 15:49
SlimShadysSlimShadys
1812
1812
5
char *strcpy(char *account[i].nome, const char *nomi[p]);is not a function call.
– Eugene Sh.
Mar 22 at 15:51
1
Changechar *strcpy(char *account[i].nome, const char *nomi[p]);tostrcpy(account[i].nome, nomi[p]);and add#include <stdlib.h>and#include <time.h>. You are also trying to provide 5 initialisers to your 4-element arrays.
– Weather Vane
Mar 22 at 15:56
add a comment |
5
char *strcpy(char *account[i].nome, const char *nomi[p]);is not a function call.
– Eugene Sh.
Mar 22 at 15:51
1
Changechar *strcpy(char *account[i].nome, const char *nomi[p]);tostrcpy(account[i].nome, nomi[p]);and add#include <stdlib.h>and#include <time.h>. You are also trying to provide 5 initialisers to your 4-element arrays.
– Weather Vane
Mar 22 at 15:56
5
5
char *strcpy(char *account[i].nome, const char *nomi[p]); is not a function call.– Eugene Sh.
Mar 22 at 15:51
char *strcpy(char *account[i].nome, const char *nomi[p]); is not a function call.– Eugene Sh.
Mar 22 at 15:51
1
1
Change
char *strcpy(char *account[i].nome, const char *nomi[p]); to strcpy(account[i].nome, nomi[p]); and add #include <stdlib.h> and #include <time.h>. You are also trying to provide 5 initialisers to your 4-element arrays.– Weather Vane
Mar 22 at 15:56
Change
char *strcpy(char *account[i].nome, const char *nomi[p]); to strcpy(account[i].nome, nomi[p]); and add #include <stdlib.h> and #include <time.h>. You are also trying to provide 5 initialisers to your 4-element arrays.– Weather Vane
Mar 22 at 15:56
add a comment |
1 Answer
1
active
oldest
votes
Should be something like
strcpy(account[i].nome, nomi[p]);
This and the reply from @Weather Vane perfectly worked.
– SlimShadys
Mar 22 at 15:59
@SlimShadys Now the big question for you: Do you understand why? And I'm curious, where did the previous line come from? Was it a copy-paste that you didn't modify correctly?
– Some programmer dude
Mar 22 at 20:18
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55303354%2ferror-expected-or-before-token%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Should be something like
strcpy(account[i].nome, nomi[p]);
This and the reply from @Weather Vane perfectly worked.
– SlimShadys
Mar 22 at 15:59
@SlimShadys Now the big question for you: Do you understand why? And I'm curious, where did the previous line come from? Was it a copy-paste that you didn't modify correctly?
– Some programmer dude
Mar 22 at 20:18
add a comment |
Should be something like
strcpy(account[i].nome, nomi[p]);
This and the reply from @Weather Vane perfectly worked.
– SlimShadys
Mar 22 at 15:59
@SlimShadys Now the big question for you: Do you understand why? And I'm curious, where did the previous line come from? Was it a copy-paste that you didn't modify correctly?
– Some programmer dude
Mar 22 at 20:18
add a comment |
Should be something like
strcpy(account[i].nome, nomi[p]);
Should be something like
strcpy(account[i].nome, nomi[p]);
answered Mar 22 at 15:55
Mikhail VladimirovMikhail Vladimirov
11.4k12631
11.4k12631
This and the reply from @Weather Vane perfectly worked.
– SlimShadys
Mar 22 at 15:59
@SlimShadys Now the big question for you: Do you understand why? And I'm curious, where did the previous line come from? Was it a copy-paste that you didn't modify correctly?
– Some programmer dude
Mar 22 at 20:18
add a comment |
This and the reply from @Weather Vane perfectly worked.
– SlimShadys
Mar 22 at 15:59
@SlimShadys Now the big question for you: Do you understand why? And I'm curious, where did the previous line come from? Was it a copy-paste that you didn't modify correctly?
– Some programmer dude
Mar 22 at 20:18
This and the reply from @Weather Vane perfectly worked.
– SlimShadys
Mar 22 at 15:59
This and the reply from @Weather Vane perfectly worked.
– SlimShadys
Mar 22 at 15:59
@SlimShadys Now the big question for you: Do you understand why? And I'm curious, where did the previous line come from? Was it a copy-paste that you didn't modify correctly?
– Some programmer dude
Mar 22 at 20:18
@SlimShadys Now the big question for you: Do you understand why? And I'm curious, where did the previous line come from? Was it a copy-paste that you didn't modify correctly?
– Some programmer dude
Mar 22 at 20:18
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55303354%2ferror-expected-or-before-token%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
char *strcpy(char *account[i].nome, const char *nomi[p]);is not a function call.– Eugene Sh.
Mar 22 at 15:51
1
Change
char *strcpy(char *account[i].nome, const char *nomi[p]);tostrcpy(account[i].nome, nomi[p]);and add#include <stdlib.h>and#include <time.h>. You are also trying to provide 5 initialisers to your 4-element arrays.– Weather Vane
Mar 22 at 15:56