Home > Back-end >  A little less?
A little less?

Time:09-22

GetBirthDate function is a id number of the date of birth to integer

# include
Void GetBirthDate (char * s) {
Int I, j=0;
For (I=6; i <14. I++) {
J *=10;
J +=s [I] - '0';
}

}

Int main (void) {
Char [] id="51010219990506001 x";
Int the date=0, year, month, day.

The date=GetBirthDate (id);
Year=date/10000;
The month=date/100% 100;
Day=date & amp; 100;
Printf (" % d % % 4 d - 02-02 d \ n ", year, month, day);

return 0;
}

CodePudding user response:

refer to the original poster ycm151 response:
GetBirthDate function is a date of birth in the id card number to an integer

# include
Void GetBirthDate (char * s) {
Int I, j=0;
For (I=6; i <14. I++) {
J *=10;
J +=s [I] - '0';
}

}

Int main (void) {
Char [] id="51010219990506001 x";
Int the date=0, year, month, day.

The date=GetBirthDate (id);
Year=date/10000;
The month=date/100% 100;
Day=date & amp; 100;
Printf (" % d % % 4 d - 02-02 d \ n ", year, month, day);

return 0;
}

Don't say you is right, you first GetBirthDate return void is no return value,
Should see what you mean is to want to return an int

CodePudding user response:

reference 1st floor gouyanfen response:
Quote: refer to the original poster ycm151 response:

GetBirthDate function is a id number of the date of birth to integer

# include
Void GetBirthDate (char * s) {
Int I, j=0;
For (I=6; i <14. I++) {
J *=10;
J +=s [I] - '0';
}

}

Int main (void) {
Char [] id="51010219990506001 x";
Int the date=0, year, month, day.

The date=GetBirthDate (id);
Year=date/10000;
The month=date/100% 100;
Day=date & amp; 100;
Printf (" % d % % 4 d - 02-02 d \ n ", year, month, day);

return 0;
}

Don't say you is right, you first GetBirthDate return void is no return value,
Should see what you mean is to want to return an int

So how to return a character array to plastic

CodePudding user response:

Regardless of algorithm, to return to the integer
Void GetBirthDate (char * s)==& gt;> Int GetBirthDate (char * s)

CodePudding user response:

refer to the original poster ycm151 response:
GetBirthDate function is a date of birth in the id card number to an integer

# include
Void GetBirthDate (char * s) {
Int I, j=0;
For (I=6; i <14. I++) {
J *=10;
J +=s [I] - '0';
}

}

Int main (void) {
Char [] id="51010219990506001 x";
Int the date=0, year, month, day.

The date=GetBirthDate (id);
Year=date/10000;
The month=date/100% 100;
Day=date & amp; 100;
Printf (" % d % % 4 d - 02-02 d \ n ", year, month, day);

return 0;
}

Atol, string is converted to digital

CodePudding user response:

Void GetBirthDate (char * s) {
Int I, j=0;
For (I=6; i <14. I++) {
J *=10;
J +=s [I] - '0';
}
}=& gt;
Int GetBirthDate (char * s) {
Int I, j=0;
For (I=6; i <14. I++) {
J *=10;
J +=s [I] - '0';
}
Return j;
}
And there's character turn the integer atoi, not l, you handled here don't have to
  • Related