Description
請撰寫一支程式,從 input.txt 讀取一個數字,然後寫入 Hello World! 到 output.txt。
Please write a program that reads a number from input.txt and then writes "Hello World!" to output.txt.
Input (From File: input.txt)
輸入包含一個整數。
Input contains an integer.
Output (To File: output.txt)
請寫入 Hello World! 到 output.txt。(不須換行)
Please write "Hello World!" to output.txt.(No need for a newline.)
Sample Input 1
32
Sample Output 1
Hello World!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
int main(){
int n = 1725;
scanf("%d",&n);
char f[10]={"\\0"};
int radix=10;
// itoa(n,f,radix);
// apparently fcu oj doesnt have itoa
sprintf(f, "%d", n);
strcat(f,".txt");
printf("%s",f);
// nvm whats above is unnessasry i misunderstood the assignment
FILE *fptr;
fptr = fopen(f,"w");
fprintf(fptr,"Hello World!");
fclose(fptr);
return 0;
}