求助,程序在文件输入与输出有些问题
帮忙复制运行一下,看看问题出在哪?程序代码:
#include<stdio.h> void int_char(long n,char s[]); long find_m(int n); void main() { int n,m,i,j; FILE *fp; fp=fopen("myf2.out","w"); printf("input a numble\n"); scanf("%d",&n); m=find_m(n); printf("n=%d m=%ld\n",n,m); fprintf(fp,"n=%d m=%ld\n",n,m); fclose(fp); } void int_char(long n,char s[]) { int i; for(i=0;n;i++) { s[i]=n%10+'0'; n/=10; } } long find_m(int n) { int i=0,j; long m; char s[20]={0}; while(1) { i++,m=n*i; int_char(m,s); for(j=0;s[j]=='0'||s[j]=='1';) { j++; if(s[j]=='\0') return m; } } }