I compile and I get this:
Miracle C Compiler (r3.2), written by bts.
Compiling C:\Users\Franccesca\Documents\Code\userInput.c
main
C:\Users\Franccesca\Documents\Code\userInput.c
line 13: & non lvalue
'scanf("%s", &buff)'
aborting compile
Here is my code, and I can't figure out why it isn't working. Does anyone have any ideas?
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- main () {
- char buff[10];
- int validInput; //1 = Good , 2 = Bad
- int i;
- //GET PURCHASE AMOUNT FROM USER
- do {
- printf("\nPlease enter purchase amount:", stdout);
- scanf("%s", &buff);
- validInput = 1; //SET TO VALID TO START
- // IF NOTHING ENTERED
- if(lstrlen(buff) == 0) validInput = 2;
- for(i = 0; i < lstrlen(buff); i++){
- if(buff[i] != 46){ // IF NOT A DECIMAL POINT
- if((buff[i] < 48) || (buff[i] > 57)){ //IF NOT 0 - 9
- validInput = 2;
- }
- }
- }
- }
- while (validInput == 2);
- }