I am trying to read a text file and tokenize the data and store in a character array.

int main(int argc , char *argv[])

printf("No of arguments %d \n",argc);
printf("Argument no 1 is %s \n" ,argv[1]);
FILE *fp;
char buffer[11];
char *bp;
char *temp;

 int i=0;  
      if ((fp = fopen(argv[1], "r"))!=NULL) {
		fread(buffer, 1, 6, fp);
    buffer[6] = 0;

    printf("first 10 characters of the file:\n%s\n", buffer);
   int x=0;
	  bp=strtok(buffer," ");
temp= bp;
  while(bp!= NULL)
  bp=strtok(NULL," ");


return 0;


Text file data is

3 5 10

You can use strcpy() to capture the strings (from tokens) into other variables.