반응형
.txt 파일에 쓰시겠습니까?
어떻게 하면 작은 글을 쓸 수 있을까요?.txt
파일이요? 검색한 지 3~4시간이 넘었는데 어떻게 하는지 모르겠어요.
fwrite();
말싸움이 너무 많아서 어떻게 써야 할지 모르겠어요.
이름과 몇 개의 숫자만 쓰고 싶을 때 가장 사용하기 쉬운 기능은 무엇입니까?.txt
파일링?
char name;
int number;
FILE *f;
f = fopen("contacts.pcl", "a");
printf("\nNew contact name: ");
scanf("%s", &name);
printf("New contact number: ");
scanf("%i", &number);
fprintf(f, "%c\n[ %d ]\n\n", name, number);
fclose(f);
FILE *f = fopen("file.txt", "w");
if (f == NULL)
{
printf("Error opening file!\n");
exit(1);
}
/* print some text */
const char *text = "Write this to the file";
fprintf(f, "Some text: %s\n", text);
/* print integers and floats */
int i = 1;
float pi= 3.1415927;
fprintf(f, "Integer: %d, float: %f\n", i, pi);
/* printing single chatacters */
char c = 'A';
fprintf(f, "A character: %c\n", c);
fclose(f);
FILE *fp;
char* str = "string";
int x = 10;
fp=fopen("test.txt", "w");
if(fp == NULL)
exit(-1);
fprintf(fp, "This is a string which is written to a file\n");
fprintf(fp, "The string has %d words and keyword %s\n", x, str);
fclose(fp);
음, 우선 C에 관한 좋은 책을 사서 언어를 이해해야 해요.
FILE *fp;
fp = fopen("c:\\test.txt", "wb");
if(fp == null)
return;
char x[10]="ABCDEFGHIJ";
fwrite(x, sizeof(x[0]), sizeof(x)/sizeof(x[0]), fp);
fclose(fp);
언급URL : https://stackoverflow.com/questions/11573974/write-to-txt-file
반응형
'sourcecode' 카테고리의 다른 글
printf()를 사용하여 열거형 값을 표시할 수 있습니까? (0) | 2022.08.01 |
---|---|
Android-sdk 설치 실패: "java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema" (0) | 2022.08.01 |
인라인 기능을 사용할 때와 사용하지 않을 때? (0) | 2022.08.01 |
64비트 머신의 사이즈(int)는 어떻게 해야 합니까? (0) | 2022.08.01 |
Vuejs. $v와 $event는 Vuejs로 무엇을 의미합니까? (0) | 2022.08.01 |