![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-10-31 12:48 |
47,815 topics / 349,930 posts / today 0 new / 48,290 members |
| DOS开发编程 & 发展交流 (开发室) » Help a brother out, there are always problems debugging this C program! Thanks, everyone. |
| Printable Version 887 / 3 |
| Floor1 honglang | Posted 2004-03-13 00:00 |
| 初级用户 Posts 27 Credits 216 | |
|
I have 2 questions to ask the experts here,
1 I'm a beginner in C. Today I wrote a program for an exam. When debugging it, there are no syntax errors anymore, but it still never outputs the correct value. Could you please point it out for me—where exactly is the mistake? main() {int a; int i=0; long sum=0; for (;i<3;i++); { scanf("%d",&a); sum+=a; } printf("%d\n",sum); } (Input an array and output the sum of the digits) 2 I'm using the XP operating system. When I use TC from the command prompt, why is it that when I switch to drive D (I installed TC on drive D), I can open it, but when executing a program it always can't open the header files, while if I install TC on drive C and run it, this problem does not occur? What's going on? Thanks for your advice! |
|
| Floor2 晓欣 | Posted 2004-03-13 00:00 |
| 初级用户 Posts 14 Credits 154 | |
|
The path is probably not set correctly. Go into Option-------->Directories and take a look.
|
|
| Floor3 honglang | Posted 2004-03-14 00:00 |
| 初级用户 Posts 27 Credits 216 | |
|
Then what about the program above? Where exactly is the mistake?
|
|
| Floor4 qzwqzw | Posted 2004-03-15 00:00 |
| 银牌会员 Posts 636 Credits 2,343 | |
|
Man, it's a very simple mistake, you're just not careful enough. It's in these two lines, you should be able to find it yourself
for (;i<3;i++); printf("%d\n",sum); Besides, this isn't really the place to discuss the C language, so not many people will answer your question. |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |