세미콜론 읽기 방지 방법; FILE에 저장하고 변수에 저장 하시겠습니까? 무시하는 방법 ';' 파일에서 fscanf?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
char gstitem[6], gstname[30],;
int gstquant, itemquant;
float gstprice;
char string[10];
printf("Purchase items fuction\n\n");
FILE *gstPtr; //pointer to the gst.txt
gstPtr = fopen ("gst.txt", "r+");
printf("Enter an item code: ");
fgets(string,10,stdin);
(!feof(gstPtr));
{
fscanf(gstPtr,"%[^;]s %[^;]s %[^;]f %[^;]d\n",gstitem,gstname,&gstprice,&gstquant);
printf("%s %s %f %s\n",gstitem,gstname,gstprice,gstquant);
}
fclose(gstPtr);
}
이
내가 절을 형식 문자열
이미지가 텍스트의 작은 양 : 질문의 일부로서 텍스트로 게시하시기 바랍니다. [Minimal, Complete, and Verifiable example] (http://stackoverflow.com/help/mcve) 아이디어는 독자가 코드와 입력 데이터를 복사하고 시도 할 수 있도록하기위한 것입니다. –
'fscanf()'의 결과를 확인하지 않으면 [_Road to Perdition_] (http://www.dictionary.com/browse/perdition), – chux
루프 이전에'fgets'의 목적은 무엇입니까? 루프 제어는 무엇입니까? (! feof (gstPtr)); [sic]가되어야하나요? [feof' (http://stackoverflow.com/questions/5431941/why-is-while-feof-file-always-wrong)의 사용에 대해 조심하는 것 외에도 루프를 제어하는 방법은 반환과 함께합니다. 'fscanf (...) == 4) {...}' –