# include & lt; Stdlib. H>
Struct student_info
{
Char snum [20].
Char sname [30].
Char sclass [30].
};
Typedef struct student_info stu.
Int main (void)
{
Stu p1 [10].
The FILE * fp=NULL;
Int I, x;
Fp=fopen (" students. TXT ", "r");
If (fp==NULL)
{printf (" \ n file open failed, ");
return 0;
}
i=0;
Fscanf (fp, "% s % s % s", & amp; P1 [I]. Snum, & amp; P1 [I]. Sname, & amp; P1 [I] sclass);
While (feof (fp)==0)
{
Printf (" % s \ \ t t % s % s \ n ", p1 [I] snum, p1 [I] sname, p1 [I] sclass);
i++;
Fscanf (fp, "% s % s % s", & amp; P1 [I]. Snum, & amp; P1 [I]. Sname, & amp; P1 [I] sclass);
}
Printf (" \ n \ n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
While (1)
{
Printf (" is point to the students is: ");
X=rand () % 10;
Print (" % s \ \ t t % s % s \ n ", p1 [x] snum, p1 [x] sname, p1 [x] sclass);
system("pause");
}
fclose(fp);
return 0;
}
Why always prompt (. Text + 0 x2da) : undefined reference to ` print '
[Error] ld returned 1 exit status
I put the while (1) that can run normally after delete, what's the problem?
CodePudding user response:
Print to print fCodePudding user response:
# include & lt; stdio.h>
# include & lt; Stdlib. H>
Struct student_info
{
Char snum [20].
Char sname [30].
Char sclass [30].
};
Typedef struct student_info stu.
Int main (void)
{
Stu p1 [10].
The FILE * fp=NULL;
Int I, x;
Fp=fopen (" students. TXT ", "r");
If (fp==NULL)
{printf (" \ n file open failed, ");
return 0;
}
i=0;
//fscanf (fp, "% s % s % s", & amp; P1 [I]. Snum, & amp; P1 [I]. Sname, & amp; P1 [I] sclass);
Fscanf (fp, "% s % s % s", p1 [I] snum, p1 [I] sname, p1 [I] sclass);
While (feof (fp)==0)
{
Printf (" % s \ \ t t % s % s \ n ", p1 [I] snum, p1 [I] sname, p1 [I] sclass);
i++;
//fscanf (fp, "% s % s % s", & amp; P1 [I]. Snum, & amp; P1 [I]. Sname, & amp; P1 [I] sclass);
Fscanf (fp, "% s % s % s", p1 [I] snum, p1 [I] sname, p1 [I] sclass);
}
Printf (" \ n \ n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
While (1)
{
Printf (" is point to the students is: ");
X=rand () % 10;
//print (" % s \ \ t t % s % s \ n ", p1 [x] snum, p1 [x] sname, p1 [x] sclass);
Printf (" % s \ \ t t % s % s \ n ", p1 [x] snum, p1 [x] sname, p1 [x] sclass);
system("pause");
}
fclose(fp);
return 0;
}
For your reference ~