lo
I have created a function that reads characters from the keyboard into a buffer. It terminates on reading a return or on recieving 128 characters.
I now want to create a function that will take a token from this buffer and place it in another array.
eg
if i got:
test test2
I would want test holding in the array, with the space being the separator.
Ne suggestions would be very welcome, code is show below.
Code:
#include <stdio.h>
#include <string.h>
int i;
char inbuff[128];
FILE *fp;
main()
{
void query();
char *gettoken(char sep);
char inbuff[128];
query();
return 0;
}
/*Reads characters from input stream into a buffer*/
void query()
{ char c;
fp=stdin;
i=0;
while ( (i<128) && (c!='\n') )
{
c=fgetc(fp);
inbuff[i]=c;
i++;
}
inbuff[i]='\0';
printf( "Currently in the buffer: %s\n", inbuff );
}