how to ascii art in c

Solutions on MaxInterview for how to ascii art in c by the best coders in the world

showing results for - "how to ascii art in c"
Emily
03 Jul 2019
1#include <stdio.h>
2#define MAX_LEN 128
3 
4void print_image(FILE *fptr);
5 
6int main(void)
7{
8    char *filename = "image.txt";
9    FILE *fptr = NULL;
10 
11    if((fptr = fopen(filename,"r")) == NULL)
12    {
13        fprintf(stderr,"error opening %s\n",filename);
14        return 1;
15    }
16 
17    print_image(fptr);
18 
19    fclose(fptr);
20 
21    return 0;
22}
23 
24void print_image(FILE *fptr)
25{
26    char read_string[MAX_LEN];
27 
28    while(fgets(read_string,sizeof(read_string),fptr) != NULL)
29        printf("%s",read_string);
30}
31