Solved

Newbie C question - EASY POINTS

Posted on 2001-07-27
2
189 Views
Last Modified: 2010-04-15
Hi
just starting out with c and have a basic question:

I am trying to prompt user for 10 numbers and take this input and load into an array. Can I do this with scanf and an expression ?

int num[];

printf "enter 10 numbers: ";
/* for statment here */
        scanf("%d", &num);


Thanks

0
Comment
Question by:neptuna
2 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 100 total points
ID: 6326948
Yes, to be precise, it would look more like:

int i,num[10];

printf("Enter 10 numbers:\n");
for(i=0; i<10; ++i)scanf("%d",&num[i]);

Note that you will have to have the subscript on num in the scanf statement. You should pass the address of ("&") the variable you want filled (num[i]).
0
 

Author Comment

by:neptuna
ID: 6327439
Thanks for the quick and accurate response !
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C simple state machine for client server handshake 4 301
why "." vs "->" 23 120
valid enum? 6 74
Using popen() and gunzip() to open file in HTTPServer 6 60
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question