高分悬赏!急!急!急!小女子有难,哪位C语言高手帮忙指点一下

来源:百度知道 编辑:UC知道 时间:2024/06/15 01:50:50
高分悬赏!我把问题发到百度贴吧了,可是久久没人回答,问题地址是http://tieba.baidu.com/f?kz=404399402

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct S_Student
{
char szName[12];
char szID[19];
}Student;

int *GetAge(char *pID, int iCurYear)
{
static int iAge = 0;
iAge = -1;

if(pID == NULL) return NULL;

char szYear[5];

memset(szYear, 0, 5);
memcpy(szYear, pID+6, 4); //截取年

iAge = iCurYear - atoi(szYear); //年龄=当前年份-所截取的年份

if(iAge < 0) return NULL;

return &iAge;
}

int main(int argc, char* argv[])
{
Student stu[] = {{"zhang","320825200102155017"},
{"li","320902198402146016"},
{"wang","320911197508265029"},
{"ya","320902195606152052"},
{"zhou","320911196401216019"}};

FILE *fp = fopen("test.txt", "w