I get an error saying "makes pointer from integer without a cast"
I'm asking the user to enter a char to choose the base. I know my readStr is correct because that is what was given by the teacher
readStr = In its simple form, this function takes one argument, the address of a char array where a C-style text string can be stored.
Code:#include <stdio.h> #include "readStr.h" #include "writeStr.h" #define BUFFER_SIZE 33 #define HEX_SIZE 9 #define BIN_SIZE 33 #define DEC_SIZE 11 #define BASE_SIZE 1 int main() { char input[BUFFER_SIZE]; char base[1]; unsigned int x; writeStr("\nEnter the base of the value to be converted"); writeStr("\n d-decimal, h-hexadecimal, b-binary: "); readStr(base, BASE_SIZE); if(base =='d' || base =='D') writeStr("Decimal"); if(base =='h' || base =='H') writeStr("Hex"); if(base =='b' || base =='B') writeStr("Binary"); return 0; } ~Code:#include <stdio.h> #include "readStr.h" #include <stdlib.h> #include <unistd.h> int readStr(char *theString, int limit) { unsigned int length =0; limit--; read(STDIN_FILENO, theString, 1); while((*theString != '\n') && (length < limit)) { theString++; length++; read(STDIN_FILENO, theString, 1); } while (*theString !='\n') read(STDIN_FILENO, theString, 1); *theString= '\0'; return length; } ~



LinkBack URL
About LinkBacks


