If you look the example, KSEQ_INIT request two variable, the first is a type variable, for your purpose use FILE* (it's defined in stdio.h), the second is a method, the text file are readed by "read" method:
KSEQ_INIT(FILE*, read); //STEP 1
I tried with fscanf and fgets, but they are wrong.
after that, you must use a connection to the file, a pointer file:
FILE* fp;
the file is open by fopen:
fp = fopen(argv[1], "r"); // STEP 2
at the end you need to close the connection.
fclose(fp); // STEP 6
that's all for the moment, I'm finding the function to read.
kseq_test_mod.c: In function 'main':
kseq_test_mod.c:16:2: warning: passing argument 1 of 'kseq_init' makes integer from pointer without a cast
kseq_test_mod.c:4:1: note: expected 'int' but argument is of type 'struct FILE *
If I run the executable:
C:\Documents and Settings\Proteomica\My Documents\Download\kseq>prova.exe sequence.fasta
return value: -1
You can try Sean Eddy's squid library. It's a general purpose sequence analysis library, but deprecated by easel (the library now used by HMMER3). See sreformat_main.c for an example of how to read sequence files of (almost) any format.
Another (general purpose) library to consider might be seqan (C++ though and haven't used it myself).
I think there used to be a C version of readseq as well, but I can only find a newer Java version.
However, all of the above might be overkill if you just want to parse fasta format, which is pretty simple.
The top answer to the following question is in pure C and works for fasta. MIT license. Which C++ Libraries Are Best For Dealing With Fastq Files?
See also: Which C++ Libraries Are Best For Dealing With Fastq Files?
The library mentioned in top answer is efficient, MIT licensed, written in C and works for both fasta and fastq.