Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (anonymous):

Can anyone help me with my C program? [error: expected ‘)’ before ‘*’ token]

OpenStudy (anonymous):

I declared my structures using typedef: typedef struct { char OrigCurr[4]; char WantCurr[4]; float ExRate; } STRUCTTYPE_Rates; typedef struct { char User[31]; char Pass[31]; char Role[14]; } STRUCTTYPE_Users; STRUCTTYPE_Rates STRUCT_Rates[100]; STRUCTTYPE_Users STRUCT_Users[100]; I'm trying to pass the parameter by pointer: int TXTDATA_Read_Rates(STRUCTTYPE_Rates* STRUCT_Rates, FILE *STREAM_Rates) { //blahblah } int TXTDATA_Read_Users(STRUCTTYPE_Users* STRUCT_Users, FILE *STREAM_Users) { //blahblah } Now when I compile, i get the following error message, for both lines above: error: expected ‘)’ before ‘*’ token What am I doing wrong?

OpenStudy (arnavguddu):

typedef struct { char User[31]; char Pass[31]; char Role[14]; } STRUCTTYPE_Users; modify to typedef struct _STRUCTYPE_Users { char User[31]; char Pass[31]; char Role[14]; } STRUCTTYPE_Users; now it should work...and also modify other struct declaration too

OpenStudy (anonymous):

How come changing 'struct' to 'struct _STRUCTTYPE_Users' will solve the problem?

OpenStudy (arnavguddu):

struct must have a name defined.....but no name is provided....

OpenStudy (arnavguddu):

try it and tell me if the error still persist or vanishes

OpenStudy (anonymous):

Error still persists.

OpenStudy (arnavguddu):

o i got it...mhy fault.. STRUCTTYPE_Rates STRUCT_Rates[100]; // ok STRUCTTYPE_Users STRUCT_Users[100]; // ok int TXTDATA_Read_Rates(STRUCTTYPE_Rates* STRUCT_Rates, FILE *STREAM_Rates) // change the argument variable names....they are already declared global variables...cannot reuse the names{ //blahblah } int TXTDATA_Read_Users(STRUCTTYPE_Users* STRUCT_Users, FILE *STREAM_Users) // same here { //blahblah } change it

OpenStudy (arnavguddu):

then tell me

OpenStudy (anonymous):

Error still persists. I changed it to : int TXTDATA_Read_Rates(DATATYPE_Rates a, FILE *b, int *c) {

OpenStudy (anonymous):

BTW I changed STRUCTTYPE to DATATYPE.

OpenStudy (arnavguddu):

attach the whole code....let me run and c wat happens

OpenStudy (anonymous):

Hold on. Let's do it one at a time. My lesser problem is the pass integer by reference one, so I'm uploading my .c file where I declared the structures as global. In this way all we have to debug first is the passing integer by reference issue.

OpenStudy (anonymous):

After fixing this one, I'm going to put the structures inside the main function and put the necessary parameters so that we can debug that problem next.

OpenStudy (anonymous):

Umm I forgot to delete the expletives in my code (lol). Just ignore it; I was using them to test if the functions were getting called correctly.

OpenStudy (arnavguddu):

i just get the following warnings::: C:\Users\Arnav\Desktop\New folder>vcvarsall Setting environment for using Microsoft Visual Studio 2010 x86 tools. C:\Users\Arnav\Desktop\New folder>cl test.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. test.c test.c(93) : warning C4047: '=' : 'int *' differs in levels of indirection from 'int' test.c(95) : warning C4047: 'return' : 'int' differs in levels of indirection fr om 'int *' test.c(116) : warning C4047: '=' : 'int *' differs in levels of indirection from 'int' test.c(118) : warning C4047: 'return' : 'int' differs in levels of indirection f rom 'int *' c:\users\arnav\desktop\new folder\test.c(52) : warning C4700: uninitialized loca l variable 'STREAM_Rates' used c:\users\arnav\desktop\new folder\test.c(53) : warning C4700: uninitialized loca l variable 'STREAM_Users' used Microsoft (R) Incremental Linker Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved. /out:test.exe test.obj C:\Users\Arnav\Desktop\New folder>

OpenStudy (anonymous):

I get these: file.c: In function ‘TXTDATA_Read_Rates’: file.c:93: warning: assignment makes pointer from integer without a cast file.c:95: warning: return makes integer from pointer without a cast file.c: In function ‘TXTDATA_Read_Users’: file.c:116: warning: assignment makes pointer from integer without a cast file.c:118: warning: return makes integer from pointer without a cast

OpenStudy (arnavguddu):

ok... got rid of all the warnings and errors... check it

OpenStudy (anonymous):

Thanks, that works now. May I ask why you put 2 asterisks in FILE **STREAM_Rates?

OpenStudy (anonymous):

Also I'm uploading the .c file again. This time we're debugging for the struct errors. Notice that I changed the parameters in function int TXTDATA_Read_Rates and it still gave me these errors: test.c:74: error: expected ‘)’ before ‘a’ test.c:99: error: expected ‘)’ before ‘STRUCT_Users’ test.c:153: error: expected ‘)’ before ‘STRUCT_Users’ test.c:175: error: expected ‘)’ before ‘STRUCT_Users’ test.c:210: error: expected ‘)’ before ‘STRUCT_Users’

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!