Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code not compiling correctly

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Please let me know what I am doing wrong. I can not get this code to compile correctly.
Thanks

#include<stdio.h>
#include<stdlib.h>
#include&quot;player.h&quot;

int* readtopps(char* fn[], int* num);
int readwants(Player* p, char* wantfn, int year);
void compare(int*, int, Player*, int);

void main(int argc,char *argv[])
{

int i, num, n1;
int* ptr;
int year[20];
char fn[80];
Player* p;
char wantfn[] = &quot;wantfile&quot;;

if(argc < 2)
{
printf(&quot;You forgot to enter years.\n&quot;);
exit(1);
}

for(i = 1; i <= argc; i++)
{
year = atoi(argv);
sprintf(fn, &quot;topps.%d&quot;, year);

ptr = (readtopps(fn, &num));
n1 = (readwants(p, wantfn, year));
compare(ptr, num, p, n1);
}
}
 
Please insert [code][/code] tags around your code or use index variable with longer name than i.

All your
Code:
[i]
have been used as start of italic TGML and removed.

I guess your code is not
Code:
year = atoi(argv);
that can not compile but
Code:
year[i] = atoi(argv[i]);
which is better.

So repost your code surrounded by the [code] [/code] TGML tags.

I fear the first argument of your call to readtops is not of the valid type, though. Readtops expects a
Code:
char *fn[]
(i.e. an array of pointer to chars which is the same, in a function argument declaration, as a pointer to pointer to chars) and you give it a
Code:
char fn[80]
(i.e. a pointer to chars).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top