• C

Function Help...

I need to develop a function that will collect the following information from the user...

Title
Type (action, comedy, etc.)
Actors (up to three)
Status (checked in, checked out)
Out To (name of customer, if checked out)

I am not very good with getting character strings from the user...

Any help?

thanks,

mapper
mapperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

luisrCommented:
Use gets()... it will read a string into a buffer.
0
ozoCommented:
fgets() would be safer
0
SlartiCommented:
Experts are prohibited from answering customers' homework assignments.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

arnondCommented:
ozo, how about scanf() or fscanf() ?

Arnon David.
0
deightonprogCommented:
#include<stdio.h>

void ans(char *type,char *act1,char *act2,char *act3,char *stat,char *outto)
{
      printf("Enter Type ");
      gets(type);
      printf("Actor 1 ");
      gets(act1);
      printf("Actor 2 ");
      gets(act2);
      printf("Actor 3 ");
      gets(act3);
      printf("status ");
      gets(stat);
      printf("Out To");
      gets(outto);
}

main()
{
char t[80],a1[80],a2[80],a3[80],s[80],o[80];
ans(t,a1,a2,a3,s,o);
printf("%s %s %s %s %s %s",t,a1,a2,a3,s,o);
getch();
}

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mapperAuthor Commented:
deighton,

I had the function part down with the gets - I was a little confused about passing the user info back to the main function.

I will play around with it thanks...

My sone wants to use this for his pokemon collection if I can get it to work...

Thanks,

Mapper
0
deightonprogCommented:
The way I did it passes a pointer (address in memory) to the beginning of the string
char *name;

when you use the name of a string (character array) without the [] you are giving a pointer to the first byte of the string, so

x is the same as &x[0]
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.