Skip to main content
gamedev.net
🔒 Locked

Code Help

Started by C Barrier Jun 20, 2002 at 10:38 AM 0 replies 300+ views
Original Post
C Barrier
C Barrier
#include <stdlib.h> int main() { int sum = 0; int x = 0; printf("Hello World\n"); printf("Input Values!\n"); scanf("%d", &x); while(x != -1) if( x > 0) { scanf("%d ", x); sum = sum + x; } else{ printf("%d", sum); system("PAUSE"); return 0; } } why does this cause an error after a second input, This code did compile correctly, i am useing DevC++ , i am newbie
rohde
rohde
In you second input, you need to write

scanf("%d ", &x);


You forgot the ampersand.

A year spent in artificial intelligence is enough to make one believe in God.

[edited by - rohde on June 20, 2002 11:44:54 AM]
"We confess our little faults to persuade people that we have no large ones." -Francois de La Rochefoucauld (1613 - 1680). | My blog

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.