I am trying to read in a string of whitespace separated strings from a file that goes like:
CGGCGGGAGATT CGGGAGATTCAA CGTGCGGCGGGA CGTGGAGGCGTG CGTGGCGTGCGG GCGTGCGGCGGG GCGTGGAGGCGT GCGTGGCGTGCG GGAGAAGCGAGA GGAGATTCAAGC GGCGGGAGATTC GGGAGATTCAAG GTGCGGCGGGAG TGCGGCGGGAGA
My code to achieve this is
char id_dna_seqs[14][12];
fscanf(dataset, "%s %s %s %s %s %s %s %s %s %s %s %s %s %s", id_dna_seqs[0], id_dna_seqs[1], id_dna_seqs[2], id_dna_seqs[3], id_dna_seqs[4], id_dna_seqs[5], id_dna_seqs[6], id_dna_seqs[7], id_dna_seqs[8], id_dna_seqs[9], id_dna_seqs[10], id_dna_seqs[11], id_dna_seqs[12], id_dna_seqs[13]);
but when I do a test printout of the array, I don't get what I expect to get. For example, doing
printf("%s\n", id_dna_seqs[4]);
gives
CGTGGCGTGCGGGCGTGCGGCGGGGCGTGGAGGCGTGCGTGGCGTGCGGGAGAAGCGAGAGGAGATTCAAGCGGCGGGAGATTCGGGAGATTCAAGGTGCGGCGGGAGTGCGGCGGGAGA
which upon closer examination, I realized is actually printing all of the strings starting from the 5th element in the char* array. What I want to achieve is to be able to individually index each string correctly for example, with reference to the strings in the file, the 5th string is the sequence CGTGGCGTGCGG, so I want printing id_dna_seqs[4] to give me just that instead of everything starting from the 5th string element.
Please let me know what is wrong here, and I look forward to your suggestions for improvement. Thank you!