一个C语言问题~~请教高手
时间:2008-05-09 09:23:16
来源:论坛整理 作者: 编辑:chinaitzhe
#include "stdio.h"
void main()
{ float b[10][10];
scanf("%f",&b[0][0]);
printf("%f",b[0][0]);
}
这个程序能编译并且运行成功
#include "stdio.h"
void main()
{ float b[10][10];
scanf("%f",&b[0][0]);
//printf("%f",b[0][0]);
}
为什么 这个就不行了呢????
还有
#include "stdio.h"
void main()
{ float b[10][10];
scanf("%f",&b[0][0]);
b[0][0]=100;
}
这个也行,但是去掉后边一句就不行了 ( 自己分数不多,狠心发50了)
网友回复:不会吧,什么错?
#include <stdio.h>
int main()
这是标准写法
网友回复:顺便说下错误信息:
Debug error!
runtime error
网友回复:运行时错误?
网友回复:
- C/C code
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ 首先头文件要 #include<stdio.h> 其次入口函数要 int main() 返回要 return 0;//不是绝对
网友回复:编译没问题 运行出错 你可以试试
网友回复:
- C/C code
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ #include "stdio.h" void main() { float b[10][10]; float c = 1.f; scanf("%f",&b[0][0]); }
网友回复:应该没有问题的
网友回复:三段程序都没有问题啊
网友回复:
能给解释下么?
网友回复:大家可以试试啊 你们的都没有问题么?那我机子的问题在哪里啊?
网友回复:scanf
之前使用一下浮点运算,付值什么的都可以
比如
- C/C code
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ #include "stdio.h" void main() { float b[10][10] = {0.0}; scanf("%f",&b[0][0]); }
网友回复:请问你们的机子调试 都没问题么?
网友回复:我刚才特意用dev c 试了
网友回复:
记得书上说,假如数组不初始化,那么他们都被默认赋值为0,你所说的和书上说的冲突么?
网友回复:
- C/C code
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ // 加上这一句是避免连接器不载入c的运行时浮点库,参见《c专家编程》 float c = 1.f;
网友回复:
刚才问了下别人,有出现这种情况的 而且我还换了台机子试试,还那样 我用的VC 我就郁闷了~!
网友回复:
- C/C code
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ 这个现象叫 Floating-point Support Not Loaded vc6.0 和更老的版本会存在这个问题,vs2005 假如你使用c编译也可能存在这个问题,使用c 编译一般就正常 这个现象的表现是,假如你在使用scanf函数之前没使用过浮点运算,那么scanf就会出错 比如 #include <stdio.h> int main() { float x ; scanf ("%f", &x) ; return 0; } 所以为了避免这个问题,你可以在scanf之前使用一下浮点运算 比如上面的改成 #include <stdio.h> int main() { float x = 0.f; scanf ("%f", &x) ; return 0; } 就没问题了
网友回复:我上面说的不一定全对,我记不清楚了,给你找了下ms的说法:
- C/C code
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ PRB: "Floating-point Support Not Loaded" Error with scanf() View products that this article applies to. Article ID : 37507 Last Review : September 17, 2003 Revision : 3.0 This article was previously published under Q37507 On This Page SYMPTOMS CAUSE RESOLUTION STATUS MORE INFORMATION Sample Code SYMPTOMS When an application uses the scanf() function to read a floating-point value from the console into an uninitialized "float" type global variable, an R6002 "floating-point format support not loaded" error occurs. This error also occurs when any formatted input routine is used to read a value. Back to the top CAUSE The compiler does not generate a reference to the __fltused variable that instructs the linker to load the floating-point support module. Back to the top RESOLUTION To work around this problem, initialize the floating-point variable or use the variable in an expression in the routine that contains the scanf() call. Back to the top STATUS This behavior is expected. To minimize the size of the executable file, the compiler loads floating-point support only when it is required. Back to the top MORE INFORMATION When a module uses only one of the formatted input routines and does not also initialize a floating-point variable, the compiler does not load floating-point support. Remove the comment indication from either or both of the two lines in the sample code below to eliminate the R6002 error. Back to the top Sample Code /* * Compile options needed: none */ #include <stdio.h> float x ; main() { // Remove the comment from the next line to eliminate the error. // x = 2.3 ; scanf ("%f", &x) ; // Remove the comment from the next line to eliminate the error. // printf ("%f\n", x) ; } Back to the top APPLIES TO ? The C Run-Time (CRT), when used with: Microsoft C Professional Development System 6.0 Microsoft C Professional Development System 6.0a Microsoft C Professional Development System 6.0a Microsoft C Professional Development System 6.0 Microsoft C Professional Development System 6.0a Microsoft C/C Professional Development System 7.0 Microsoft Visual C 1.0 Professional Edition Microsoft Visual C 1.5 Professional Edition Microsoft Visual C 5.0 Learning Edition Microsoft Visual C 2.0 Professional Edition Microsoft Visual C 4.0 Professional Edition Microsoft Visual C 5.0 Professional Edition Microsoft Visual C 6.0 Professional Edition
网友回复:原来是这样 呵呵,被他困扰了有一个多小时了 谢谢各位了 结分去了!^_^
网友回复:http://support.microsoft.com/kb/q37507/
网友回复:我运行起来没有任何错误
C:\Documents and Settings\IBM_T23>vim main.c
gcc main.c
main.c: In function `main':
main.c:4: warning: return type of 'main' is not `int'
./a.out
1.2
1.200000
网友回复:
可是为什么
#include <stdio.h>
int main()
{ float b[10][10];
scanf("%f",&b[0][0]);
printf("%f",b[0][0]);
}
这样也是对的呢?
难道 它在调试时也先进行了浮点运算
网友回复:
那就是我用的编译器的问题了 ^_^ 谢谢
网友回复:http://support.microsoft.com/kb/q37507/
中文的 - -
网友回复:哦了 Chiyer说得对 呵呵 编译器的 问题 唉。。。以后还是尽量学LINUX吧^_^
网友回复:
- C/C code
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ msdn上的说法 Visual C Concepts: Building a C/C Program C Run-Time Error R6002 Error Message floating-point support not loaded The necessary floating-point library was not linked. To fix by checking the following possible causes 1. The program was compiled or linked with an option, such as /FPi87, that requires a coprocessor, but the program was run on a machine that did not have a coprocessor installed. 2. A format string for a printf_s or scanf_s function contained a floating-point format specification and the program did not contain any floating-point values or variables. 3. The compiler minimizes a program's size by loading floating-point support only when necessary. The compiler cannot detect floating-point format specifications in format strings, so it does not load the necessary floating-point routines. 4. Use a floating-point argument to correspond to the floating-point format specification, or perform a floating-point assignment elsewhere in the program. This causes floating-point support to be loaded. 5. In a mixed-language program, a C library was specified before a FORTRAN library when the program was linked. Relink and specify the C library last.
网友回复:这是TC的一个小bug,不能直接用scanf输出float二维数组元素
解决方法是先定义一个float temp;用scanf给temp赋值,然后用赋值语句将temp的值赋给二维数组元素
网友回复:无聊的问题
GCC运行正常
关键字:一个,语言,问题,请教,高手,
上一篇:下午,换休,真爽。
下一篇:下面没有链接了











文章评论
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面