C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 2nd, 2013, 11:39 PM
Viraj Gamage Viraj Gamage is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 6 Viraj Gamage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 1 m 58 sec
Reputation Power: 0
Post Getting user inputs in C programming

I am new to C and I have followed Java before.I study C for my future studies.The problem i get is I cannot input user inputs to an array and print it .This is my code:-

#include <stdio.h>

int main(void)
{
int arr[3];
int i,j;

for(j=0; j<3; j++){
scanf("%d\n", arr[j]);
}

for(i = 0; i < 3 ;i++)
printf("%d\n",arr[i]);


return 0;
}

can some one help me to correct this please!

Reply With Quote
  #2  
Old January 3rd, 2013, 12:56 AM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,840 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 19 h 19 m 34 sec
Reputation Power: 1774
1. Please use [code][/code] when posting code.

2. scanf("%d\n", arr[j]);
scanf needs a pointer to store each converted result.
So
scanf("%d\n", &arr[j]);
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper

Reply With Quote
  #3  
Old January 3rd, 2013, 05:58 AM
Viraj Gamage Viraj Gamage is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 6 Viraj Gamage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 1 m 58 sec
Reputation Power: 0
Quote:
Originally Posted by salem
1. Please use [code][/code] when posting code.

2. scanf("%d\n", arr[j]);
scanf needs a pointer to store each converted result.
So
scanf("%d\n", &arr[j]);


Thnks for ur answer..I got it..
And i say you I am not an indian
Is that the way u get ur marks for xm(writing 4n number on ur xm paper ??)

Reply With Quote
  #4  
Old January 3rd, 2013, 06:23 AM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,840 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 19 h 19 m 34 sec
Reputation Power: 1774
It's a signature link, not aimed at you specifically.

It's just for anyone who thinks they can somehow scam their way through an education by either cheating or corruption.
We get a lot of "please do it for me" posts on forums, and the link is a useful reminder for those kinds of people.

Reply With Quote
  #5  
Old January 3rd, 2013, 07:04 AM
Viraj Gamage Viraj Gamage is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 6 Viraj Gamage User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 1 m 58 sec
Reputation Power: 0
Quote:
Originally Posted by salem
It's a signature link, not aimed at you specifically.

It's just for anyone who thinks they can somehow scam their way through an education by either cheating or corruption.
We get a lot of "please do it for me" posts on forums, and the link is a useful reminder for those kinds of people.


you may be a genius man at computing. you have registered here in 2005.that means you are at least 7 years experienced.As an experienced man do not look at each and every man as cheaters. Think of your early days..You too may have these kind of problems which are little but gives biginer huge headaches.

personally, I am a computer science student currently i am on a vacation after completing first year studies..I studied Java in fist year as a introduction to programming.I have to study the module operating systems in my second year.So i thought to have a knowledge of C language as OS module based on it.

I do not know from where you are.But I have heard of people(mostly from Europe.)who put their assignments on sites(such as Fiverr) and get them completed for money..Mind you,,Lot of Indians work on that sites and do others work for money..(I am not an Indian)..

There are cheaters everywhere..But not all

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Getting user inputs in C programming

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap