Click here to Skip to main content
11,639,765 members (60,052 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C
struct customer{
   char name[30];
   int noOfCustomer;

the question is write a statement which can receive input from user to be assigned to struct member namely name, int noOfCustomer, total_pay;

may i know what is the question is asking about?
is it write 30 name of the struct name like that?
Posted 28-Apr-11 10:11am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I reckon, you are looking for something like this:

struct customer
    char name[30];
    int noOfCustomer;
    int total_pay;
void Foo()
    struct customer cust;
    scanf("%d", &cust.noOfCustomer);
    scanf("%d", &cust.total_pay);

These are very basic questions though. So you'll save a lot of time if you just get an introductory C text book.
Jayfam at 28-Apr-11 16:23pm
ya, im new in this chapter
Nishant Sivakumar at 28-Apr-11 16:25pm
Yeah, and a good book will really help a lot. That said, feel free to ask questions here. It's good to see someone trying stuff out on their own.
Jayfam at 28-Apr-11 16:28pm
ok, i will try hard on it
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I believe they're asking you to pull in a number of arguments at once. <--Not sure if I interpreted this correctly

Use scanf()(or one of its derivatives) to pull in several arguments at once:[^]

The name portion of the question, well, that'll limit your input name buffer to 30 characters, so as long as input doesn't exceed that. A more bulletproof method would be to use a char * and dynamically allocate the memory, but that may be a bit too advanced at this stage.
Jayfam at 28-Apr-11 16:29pm
thanks for the explanation

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Suvendu Shekhar Giri 330
1 CPallini 177
2 F-ES Sitecore 170
3 sasanka sekhar panda 155
4 142
0 OriginalGriff 9,081
1 Sergey Alexandrovich Kryukov 8,847
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,650
4 F-ES Sitecore 2,558

Advertise | Privacy | Mobile
Web03 | 2.8.150731.1 | Last Updated 28 Apr 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100