Results 1 to 3 of 3
my program is:
Code:
#include <stdio.h>
int main(void)
{
int max_item;
printf("please input number");
scanf("&#37;d", &max_item);
int array[] = max_item;
scanf("%lf", array[0];
printf("%lf", array[0])
getch();
}
help i dont know ...
- 01-06-2008 #1Just Joined!
- Join Date
- Jan 2008
- Posts
- 1
Program help needed
my program is:
help i dont know about it really,. all i want to do is to make a program that can accept inputs using an array., thankyou., hope to hear from you soon..Code:#include <stdio.h> int main(void) { int max_item; printf("please input number"); scanf("%d", &max_item); int array[] = max_item; scanf("%lf", array[0]; printf("%lf", array[0]) getch(); }Last edited by devils casper; 01-06-2008 at 10:09 AM. Reason: added [code].....[/code] tag.
- 01-06-2008 #2Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
I've moved this to its own thread. Please post new threads for new problems to allow it to be addressed properly.
- 01-06-2008 #3
- You have syntax errors in your code. I know this isn't in the rules, but normally you can show great courtesy by cleaning them up before posting the code. That's because we're unpaid volunteers, and it's nice for us not to have to do that for you when we want to experiment with your code by compiling it ourselves and modifying it as necessary.
Of course, that doesn't apply if you have a question about why you got a syntax error. - In particular, you have declared two data items (of different types) called max_item. Any particular reason to call them both the same name? It won't work.
- Don't use scanf(). I explain why here. Instead, use fgets() to read a line of input at a time, and use sscanf() to parse that line into your variables.
Of course, at this point someone might show how C++ has even better ways to do the input, but that wasn't your question. :) - What's that getch() doing in there?
--
Bill
Old age and treachery will overcome youth and skill.
- You have syntax errors in your code. I know this isn't in the rules, but normally you can show great courtesy by cleaning them up before posting the code. That's because we're unpaid volunteers, and it's nice for us not to have to do that for you when we want to experiment with your code by compiling it ourselves and modifying it as necessary.


Reply With Quote