写一个c语言程序,其中必须包含下列代码:
float a,b;
int i,j;
char c1,c2,c3;
int Retcode;
Retcode=fscanf(stdin,"%o 2%ld %c 5%c %c %f %f",
&i,&j,&c1,&c2,&c3,&b,&a);
要从一个文件,Text2.in中读取数据
Text2.in的内容如下:
***77**243567\n
*2.4e3**14.7\n
172**\n
其中*号是空格,
要求得到i,j,c1,c2,c3,b,a,Retcode这几个变量的值?
我写的代码是:
This is a part of a program:
float a,b;
int i,j;
char c1,c2,c3;
int RetCode;
RetCode=fscanf(stdin," %o 2%ld %c 5%c %c %f %f ",&i,&j,&c1,&c2,&c3,&b,&a);
i need use this program to read some information from a file which named "Text2.in",
i am going to show you what's in the file "Text2.in"
***77**243567\n
*2.4e3 14.7\n
172**\n
i used * replace blank,in reality they are blanks
and the question is what's the value of Retcode,a,b,i,j,c1,c2,c3????
now i am going to show you my program
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
float a,b;
int i,j;
char c1,c2,c3;
int Retcode;
FILE*fp;
stdin = fopen("Text2.in","r");
Retcode=fp(stdin,"%o 2%ld %c 5%c %c %f %f", &i,&j,&c1,&c2,&c3,&b,&a);
system("pause");
return 0;
}
不知道对不对,帮忙看一下.
值我运行完程序都知道了,大家也不用告诉我,只是不知道程序是怎么读的,希望可以解说一下?还有为什么Retcode的值为3?
我如果把代码改成这样的话:
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
float a,b;
int i,j;
char c1,c2,c3;
int Retcode;
FILE*stdin;
stdin = fopen("Text2.in","r");
Retcode=fscanf(stdin,"%o 2%ld %c 5%c %c %f %f", &i,&j,&c1,&c2,&c3,&b,&a);
system("pause");
return 0;
}
就会报错了,就是把原来fp的地方换成stdin,不能运行,为什么?希望高手可以说下stdin是什么?
希望大家认真看完,帮忙解答下每个问题,对我非常重要!!谢谢