GRY-Online.pl --> Archiwum Forum

Kompilacja programu.

24.02.2009
20:41
[1]

hopkins [ Zaczarowany ]

Kompilacja programu.

Mam kod programu na projekt:
#include<stdio.h>
#include<stdlib.h>

void lending()‹
int t;
char buffer[30];
FILE *p;
p=fopen("books.txt","at");

printf("Type the title of a hired book ");
scanf("%s",buffer);
fprintf(p,"%s ",buffer);

printf("Type the author ");
scanf("%s",buffer);
fprintf(p,"%s\n",buffer);

fclose(p);
p=fopen("people.txt","at");

printf("Type the name of man, who is hiring the book ");
scanf("%s",buffer);
fprintf(p,"%s ",buffer);

printf("Type the surname of man, who is hiring the book ");
scanf("%s",buffer);
fprintf(p,"%s\n",buffer);
fclose(p);

p=fopen("time.txt","at");
fprintf(p,"%ld ",time(NULL));
printf("How many weeks can this book be hired? ");
scanf("%d",&t);
fprintf(p,"%d\n",t);
fclose(p);


int spec_book()‹
char title[30], author[30],aux[30],b;
int i,j;
FILE *p;
p=fopen("books.txt","rt");

printf("Type the title of book being searched for ");
scanf("%s",title);
printf("Type the author of book being searched for ");
scanf("%s",author);

i=1;
while(!feof(p))‹
fscanf(p,"%s",aux);
if(!strcmp(aux,title))‹
fscanf(p,"%c");
fscanf(p,"%s",aux);
if(!strcmp(aux,author)) goto sk1;

i++;

sk1:

if(feof(p)) return 1;

j=1;
fclose(p);
p=fopen("people.txt","r");

while(j<i-1)‹
fscanf(p,"%c",&b);
if(b=='\n') j++;

fscanf(p,"%s",title);
printf("%s ",title);
fscanf(p,"%c");
fscanf(p,"%s",title);
printf("%s\n",title);
fclose(p);
return 0;


void too_long()‹
FILE* p,*data;
char b,buffer[30];
long int t;
int howlong,i,j;
p=fopen("time.txt","rt");
data=fopen("people.txt","rt");
j=1;
i=1;
while(!feof(p))‹
fscanf(p,"%ld",&t);
fscanf(p,"%d",&howlong);
if(time(NULL)>t+howlong*604800)‹
while(j<i-1)‹
fscanf(data,"%c",&b);
if(b=='\n') j++;

fscanf(data,"%s",buffer);
printf("%s ",buffer);
fscanf(data,"%c");
fscanf(data,"%s",buffer);
printf("%s\n",buffer);

i++;

fclose(p);
fclose(data);


int menu()‹
int x;
printf("What to do?\n1:Lending new book\n2:Who has specified book?\n3:Who keeps a book too long\n4:Exit\n");
scanf("%d",&x);
return x;


int main()‹

int choice;

choice=menu();
while(1)‹
while((choice>4)||(choice<1)) choice=menu();
switch(choice)‹
case 1:
lending();
break;
case 2:
spec_book();
break;
case 3:
too_long();
break;
case 4:
goto sk;

choice=menu();

sk:
return 0;


U kolegow sie kompiluje, a u mnie pojawiaj sie 4 errory.
1>c:\documents and settings\łukasz\moje dokumenty\visual studio 2008\projects\project\project\main.cpp(31) : error C3861: 'time': identifier not found
1>c:\documents and settings\łukasz\moje dokumenty\visual studio 2008\projects\project\project\main.cpp(52) : error C3861: 'strcmp': identifier not found
1>c:\documents and settings\łukasz\moje dokumenty\visual studio 2008\projects\project\project\main.cpp(55) : error C3861: 'strcmp': identifier not found
1>c:\documents and settings\łukasz\moje dokumenty\visual studio 2008\projects\project\project\main.cpp(92) : error C3861: 'time': identifier not found

Wiecie czemu? :)

24.02.2009
20:41
[2]

EG2007_20979921 [ Chorąży ]

......xD

24.02.2009
20:44
[3]

pecet007 [ - ]

wklej to na jakieś bo gol psuje znaczki ale stawiałbym że musisz zainkludować time.h i string.h

24.02.2009
20:46
[4]

hopkins [ Zaczarowany ]

Prosze:
Zainkludowalem i teraz takie cos sie wysypalo:
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol [email protected] referenced in function ___tmainCRTStartup
1>C:\Documents and Settings\Łukasz\Moje dokumenty\Visual Studio 2008\Projects\Project\Debug\Project.exe : fatal error LNK1120: 1 unresolved externals

24.02.2009
21:01
[5]

pecet007 [ - ]

You probably need to set Project->properties->linker->system->subsystem to CONSOLE

24.02.2009
21:09
smile
[6]

hopkins [ Zaczarowany ]

Pecet007 wielkie dzieki :)
Wisze Ci piwo!

© 2000-2021 GRY-OnLine S.A.