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

19 lines
376 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[])
{
FILE *file = fopen("output.txt", "w");
if(file)
{
for(int Index = 1; Index < argc; Index++)
{
char *CurrentString = argv[Index];
fprintf(file, "%s ",CurrentString);
}
fclose(file);
}
}