

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A series of exercises for the third week of c programming. The exercises cover various topics such as file i/o, string manipulation, and array processing. Students are expected to write programs to solve these exercises, some of which involve modifying existing code or creating new functions.
Typology: Exercises
1 / 3
This page cannot be seen from the preview
Don't miss anything!


C Programming, Exercises for the third week
#include <stdio.h> int main( int argc, char *argv [ ]) { int ch; FILE *fptr; fptr = fopen( argv[ 1 ], "r"); while ((ch = getc( fptr )) != EOF) if (ch == โ โ || ch == โ\tโ) putchar (โ\nโ); else putchar (ch); fclose (fptr); return 0; }
struct map { int width; int height; char* data; };
Write a function struct map load_map(char filename) that loads in a map of the following format. The map is always rectangular, and its walls are defined by โ*โ. Sample map: (you should be able to copy-paste it into a file).
Hint: Use previous functions here, you can get the file length, data and line breaks from the previous tasks.
width: 12, height: 7