Beginning C Programming - Part 47 - Read Text From A File By Character

preview_player
Показать описание
We chatter on this Discord server:

Series of videos on programming in C

I've added ads, as it seems it's the only way to appear in searches!
Рекомендации по теме
Комментарии
Автор

thanks for this video, this clarified a lot for me, theres hardly any information on this explained simply like this

HamedAdefuwa
Автор

how can I get the number of all characters of a sentence using the while loop?

ksp
Автор

Hello, I really enjoy how easy it is to follow along with you but i have a question.

If i only wanted it to read the first two lines how would I go about that? Thanks!

vanon
Автор

fscanf(formatted output) is equivalent to fgetc?

AbhimanyuAryan
Автор

 is their anyway with which i can count the number of char in the file and then multiply them with the sizeof() ?

#include <stdio.h>
#define MAX 512

int main()
{
    FILE *fp = fopen("file.txt", "r");

    int line =0;

    char *input;

    while(fgets(input, sizeof(char)*MAX, fp)){
        line++;
        printf("%d->%s", line, input);
    }
    fclose(fp);

    return 0;
}

AbhimanyuAryan
visit shbcf.ru