icp/oer/courses/c-basics/sections/26-files/02-write/program.c

21 lines
512 B
C

#include <stdlib.h>
#include <stdio.h>
// This time we make a simple program, which just writes its arguments into a file
int main(int argc, char *argv[])
{
// TODO: read up on all the modes and choose the one, that creates a new file and dicards the old one.
FILE *file = fopen("output.txt", "");
if(file)
{
for(int Index = 0; Index < argc; Index++)
{
char *CurrentString = argv[Index];
// TODO: print the string into the file. Each one in a new line
// TIP: fprintf
}
fclose(file);
}
}