I have a problem with get.
the goal is to get input from the user until he reaches 'Enter'
this is the code:
struct LinkedListNode* executeSection2()
{
char inputArr [3] = {'\0'};
struct LinkedListNode* newNode;
struct LinkedListNode* head = NULL;
gets (inputArr);
while (inputArr[0] != 0) // The user didn't press "Enter"
{
newNode=newLinkedListNode();
newNode->tree=newHuffmanNode(inputArr[0],atoi(inputArr+2));
head = addNode(&head, newNode);
gets (inputArr);
}
head = buildHuffmanTree(&head);
return head;
}
it seems ok, the user clicks on 'Enter', the code exits from this point, but after returning I get an error message:
Stack around the variable 'inputArr' was corrupted
I guess I didn’t read the keyboard input correctly. I will be happy for some guidance.
thank.
source
share