12,402,666 members (73,521 online)
Rate this:
See more:
```struct customer{
char name[30];
int noOfCustomer;
total_pay;
}```

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

is it write 30 name of the struct name like that?
Posted 28-Apr-11 10:11am
Jayfam469

Rate this:

## 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("%s", cust.name);
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 28-Apr-11 16:23pm

ya, im new in this chapter
Nishant Sivakumar 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 28-Apr-11 16:28pm

ok, i will try hard on it
Rate this:

## 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:
http://en.wikipedia.org/wiki/Scanf[^]

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.
v3
Jayfam 28-Apr-11 16:29pm

thanks for the explanation

Top Experts
Last 24hrsThis month
 OriginalGriff 310 Karthik Bangalore 215 Richard Deeming 198 Richard MacCutchan 173 F-ES Sitecore 135
 OriginalGriff 7,158 ppolymorphe 3,030 Karthik Bangalore 2,952 Richard MacCutchan 2,250 F-ES Sitecore 2,187