I have a simple question.
Is it possible for a C variable to have a user-defined name?
Imagine this:
I have a function lets call it: create_new
It receives a string, lets call it: name[ ]
So the function looks like this:
char create_new(char name[ ])
My question is, can I use the characters in name[ ], to attribute a user-defined name to the string of chars that will be returned by the function. If not, how else can I attribute a user chosen name to a char string?
LightSystem
0
Newbie Poster
Recommended Answers
Jump to PostNot sure just what you are asking Do you want the contents of the array name to contain some text that the user entered via keyboard ?
char name[80] = {0}; printf("Enter your name\n"); fgets(name,sizeof(name), stdin); printf("You entered %s\n", name);
All 4 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
LightSystem
0
Newbie Poster
jephthah
1,888
Posting Maven
Salem
5,138
Posting Sage
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.