如何解决无法扫描文件,无法捕获换行符
(node:6213) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection,use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:6213) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
struct card{
char face[3];
char suit[4];
};
typedef struct card Card;
struct stack{
Card cardd;
struct stack *nextPtr;
};
typedef struct stack Stack;
int resume_match(Stack *stacks,Stack *basestacks){
FILE *fp = fopen("match_saved.txt","r");
Card card;
Stack *stacksPtr;
char tmp;
for (size_t i=0; i<10; ++i){
do{
if (fscanf(fp,"%s%s ",card.face,card.suit)==2){
// it doesn't reach here
stacksPtr = &(stacks[i]);
additem(card,&stacksPtr);
}
} while (fscanf(fp,"\n")); // this should be able to stop the while once I reach another line
}
fclose(fp);
}
是这样的(是的,每行的开头都有一个空格):
match_saved.txt
我不知道如何抓住所有这些卡并将其值放入card.face和card.suit中。 stdin指令有问题,我猜换行符。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。