728x90
반응형
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
FILE* fp = fopen("C:\\Users\\hrmk\\OneDrive\\바탕 화면\\text\\data.txt", "rt");
if (fp == NULL)
{
puts("Failed to open file.");
return -1;
}
//for (int i = 0; i < 3; i++)
//{
// int ch = fgetc(fp);
// printf("%c\n", ch);
//}
int ch;
char str[30];
ch = fgetc(fp);
printf("%c\n", ch);
ch = fgetc(fp);
printf("%c \n", ch);
fgets(str, sizeof(str), fp);
printf("%s", str);
fgets(str, sizeof(str), fp);
printf("%s", str);
//fputc('A', fp);
//fputc('B', fp);
//fputs("My name is Jake\n", fp);
//fputs("Your name is Mike\n", fp);
fclose(fp);
return 0;
}
728x90
반응형
'Language > C & C++' 카테고리의 다른 글
[C] Read a file and remove the spaces between words (0) | 2022.10.23 |
---|---|
[C] Function to remove spaces from a string (0) | 2022.10.22 |
Function practice (0) | 2022.10.19 |
[Instant]Homework (0) | 2022.10.18 |
[C++]Related to Copy Constructor (0) | 2022.10.17 |