Home > Back-end >  Always said is not defined clearly defines the variable? [Error] 'the scanf' was no declar
Always said is not defined clearly defines the variable? [Error] 'the scanf' was no declar

Time:09-19

#include
#include /* use malloc () */
Struct data/* defined structure */
{int day, month, year;
};
Typedef struct/* defined structure */
{char name [20].
long num;
Struct data birthday;/* nested structure type members */
} stu.
Int main (int arg c, char * * argv) {
Stu * student1;
Stu student2;
Student1=(stu *) malloc (10 * sizeof (char));
//studnet2=malloc sizeof (struct stu));
Printf (" Input the name, num, year, month, day,/n ");
The scanf (" % s ", student1 - & gt; Name);
The scanf (" % ld ", & amp; Student1 - & gt; Num);
The scanf (" % d % d % d ", & amp; Student1 - & gt; Birthday year, & amp; Student1 - & gt; Birthday month, & amp; Student1 - & gt; Birthday. Day);
Printf ("/nOutputname, number, year, month, day/n ");
Printf (" % s % 10 ld % 10 20 d////% d % d/n ",
Student2. The name,
Student2 num,
Student2. Birthday. Year,
Student2. Birthday. The month,
Student2. Birthday. Day);
return 0;
}

CodePudding user response:

Plus the header file
# inlcude & lt; stdio.h>

CodePudding user response:

 # include & lt; Iostream> 
#include /* use malloc () */
#include //or & lt; Cstdio>


using namespace std;
Struct data/* defined structure */
{
Int day, month, year;
};

Typedef struct/* defined structure */
{char name [20].
long num;
Struct data birthday;/* nested structure type members */
} stu.
Int main (int arg c, char * * argv) {
Stu * student1;
Stu student2;
//student1=(stu *) malloc (10 * sizeof (char));
Student1=(stu *) malloc (10 * sizeof (char));//here apply for insufficient space, use the following more appropriate
//studnet1=malloc sizeof (struct stu));
//studnet2=malloc sizeof (struct stu));
Printf (" Input the name, num, year, month, day,/n ");
The scanf (" % s ", student1 - & gt; Name);//here already crossed
The scanf (" % ld ", & amp; Student1 - & gt; Num);
The scanf (" % d % d % d ", & amp; Student1 - & gt; Birthday year, & amp; Student1 - & gt; Birthday month, & amp; Student1 - & gt; Birthday. Day);
Printf ("/nOutputname, number, year, month, day/n ");
Printf (" % s % 10 ld % 10 20 d////% d % d/n ",
Student2. The name,
Student2 num,
Student2. Birthday. Year,
Student2. Birthday. The month,
Student2. Birthday. Day);
return 0;
}

For your reference ~
  • Related