Hello forum,
So i was attempting to read a value input from the user such as "123" or "234552" etc. from the PuTTY and store it into a int variable.
Ex.
user input = 1234
stored value into.....
int = user input =1234;
I had tried some ways using a char pointer and using UARTChartGet(base) but it was not not storing it properly.
void UART_InString(char *bufPt, unsigned short max) // max is number of chars, and *bufPt points back to a : char Instring; { int i; int length=0; char character; *bufPt = 0; character = UARTCharGet(UART0_BASE); while(character != 13)// number for carriage return { if(character == 8)// number for backspace { if(length){ bufPt--; length--; UARTCharPut(UART0_BASE, 8); } } else if(length < max){ *bufPt = character; bufPt++; length++; UARTCharPut(UART0_BASE, character); } character = UARTCharGet(UART0_BASE); } }
i hope i was on the right path. I was also planning on using atoi() function after the value was input to transfer to int variabe not sure how yet. Also if there is an easier way please point me in the right direction if possible.