This is my problem:
A function to get input from the user. This function takes one argument (a character string that is the prompt for the user when entering input), prints the prompt, reads a single integer from standard input, and returns the integer value that was entered.
Would I write the function:
int prompt (char a)
char a = "enter number of %s"
int main (void)
char a = twenties;
I am not really sure how to write a function that prompts a user to enter a certain amount of money and then returns the value so that I can input it into some math functions. Any help would be appreciated.
function to get input from a user
Post a Reply
|Oldest Newest Rating|
· February 6, 2016
Why is prompt of type int, if you don't return anything relevant?
char a can only hold one byte, not an entire string.
You pass char a as an argument but then you redeclare char a inside the prompt function.
You declare char a in main and assign it to some unknown variable twenties.
You then pass a into prompt which is a bit redundant because you already declare and assigned it then you redeclare and reassign it in prompt.
If you intended on passing a pointer to a inside the prompt function then assign it inside the prompt function, well you're just passing a copy.
You are not printing anything to the user.
You don't need to write a function for input and output, they already exist.
· February 17, 2016
His earlier tut vids explain how to get user input; this particular tut vid is probably more what you're looking for.
One of the most popular languages of all time.
|Bucky Roberts Administrator|