小弟一点关于sacnf_s的问题 求带老帮一下我
程序代码:
#include <stdio.h> #include <windows.h> #define LONG 2 #define WIDE 2 #define SIZE sizeof(LINK)*300 #define READNUM 2 typedef struct link { int num; char name[80]; int year; struct link * next; }LINK; void Draw(void); void SetCurSor(int X,int Y); void Chice(int i); FILE * OpenTxT(void); LINK* ReadTxT(const FILE * fp); // static char content[SIZE]; int main(void) { FILE *fp= OpenTxT(); if (fp != NULL) { ReadTxT(fp); } Draw(); getchar(); return 0; } void Draw(void) { COORD position = { 0,0 }; HANDLE handleout = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO csbi; position.X = LONG; position.Y = WIDE; SetConsoleCursorPosition(handleout,position); printf("**********************************************************"); GetConsoleScreenBufferInfo(handleout, &csbi); position = csbi.dwCursorPosition; for (size_t i = 0; i < 10; i++) { SetConsoleCursorPosition(handleout, position); printf("*"); position.Y++; } position.X = LONG; position.Y = WIDE+10; SetConsoleCursorPosition(handleout, position); printf("***********************************************************"); position.X = LONG; position.Y = WIDE; SetConsoleCursorPosition(handleout, position); for (size_t i = 0; i < 10; i++) { position.Y++; SetConsoleCursorPosition(handleout, position); printf("*"); } SetCurSor(5, 5); printf("1.创建新的链表 ************* 2.查看全部链表"); SetCurSor(5, 9); printf("3.加入项到链表中 ************* 4.删除链表中的项"); SetCurSor(0, 13); } void SetCurSor(int X, int Y) { COORD position; position.X = X; position.Y = Y; HANDLE handleout = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleCursorPosition(handleout, position); return; } FILE * OpenTxT(void) { FILE * Fp; Fp=fopen("LinkList.txt", "r"); if (Fp==NULL) { printf("文件打开失败!"); fclose(Fp); return NULL; } else { printf("文件打开成功."); return Fp; } } LINK* ReadTxT(const FILE * fp) { LINK*head, *prv, *correct; head = (LINK*)malloc(sizeof(LINK)); int count = 0; while(!feof(fp)) { if (fgetc(fp) == '\n') count++; } fseek(fp, 0L, SEEK_SET); if (fscanf_s(fp, "%s\t%d\n", correct->name, sizeof(char[80]), &correct->year, sizeof(int)) == READNUM) { int readnum = 1; prv = head; for (int i = 1; i <= count; i++) { correct = (LINK*)malloc(sizeof(LINK)); correct->next = NULL; prv->next = correct; if (fscanf_s(fp, "%s\t%d\n",correct->name,sizeof(char[80]),&correct->year,sizeof(int)) == READNUM) { readnum++; prv = prv->next; } else { printf("第%d个读取失败!", readnum); break; } } if (readnum == count) { printf("全部读取成功!"); } else { printf("一共读取%d个.", readnum); } } return head; } 先贴代码 问题出现在: if (fscanf_s(fp, "%s\t%d\n", correct->name, sizeof(char[80]), &correct->year, sizeof(int)) == READNUM) 这一行中 VS2015一直提示引用冲突啥的 求各位带老给看下谢谢!!