Code:
#include <stdio.h>
#include "readIn.h"
#include <string.h>
#define BUFFER_SIZE 9
int main()
{
char *n;
n=malloc(BUFFER_SIZE);
printf("Enter a Hexadecimal >> ");
scanf("%s",n);
readIn(n, BUFFER_SIZE);
return 0;
}
Code:
#include <stdio.h>
#include "readIn.h"
int readIn(char *theString, int limit)
{
int length =0;
limit--;
read(STDIN_FILENO, the String, 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;
}