There are a few point in your code that should be addressed. int main(void) or int main(int argc, char **argv) are correct. Unless you have a very specific reason, do not use any other signature for main. For functions which accept no arguments, use an explicit void instead of omitting the argument list. It's not 1987.
You must always check the value returned by scanf, and you should use a width modifier for each conversion. Even simple code using a raw %d may exhibit undefined behavior on some inputs (in particular, if the input string cannot fit in an integer). Usually, casual code does not bother limiting the input on %d conversions, but you should always limit your reads for %s to no more than one less than the size of the buffer and always check the return value. It is safest to just avoid scanf completely. Learning its foibles will not be enlightening, and you will wind up burning a lot of time on stupid bugs.
Don't bother with the typedef. They are useful for complicated function definitions and for hiding opaque types. Neither of those situations applies here.
Passing the structure by value can be very expensive. It is more idiomatic not to.
#include <stdio.h>
#include <stdlib.h>
struct customer
{
char name[256];
int age;
};
void
inputCustomerDetails(struct customer *new_cust)
{
printf("Enter your name: ");
if( scanf("%255s", new_cust->name) != 1 ){
fprintf(stderr, "invalid input\n");
exit(EXIT_FAILURE);
}
printf("Enter your age: ");
if( scanf("%4d", &new_cust->age) != 1 ){
fprintf(stderr, "invalid input\n");
exit(EXIT_FAILURE);
}
}
int
main(void)
{
struct customer customer[5];
struct customer *last = customer + sizeof customer / sizeof *customer;
struct customer *cust;
for( cust = customer; cust < last; cust += 1 ){
inputCustomerDetails(cust);
}
return EXIT_SUCCESS;
}
scanf("%255s", new_cust.name);andscanf("%d", &new_cust.age);. Note the usage of%dinstead of%sand the presence of&. Also, check the return value. egif( scanf(...) != 1 ){ fprintf(stderr, "input error\n"); ... }