aboutsummaryrefslogtreecommitdiff
path: root/count_nucleobases.c
diff options
context:
space:
mode:
Diffstat (limited to 'count_nucleobases.c')
-rwxr-xr-xcount_nucleobases.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/count_nucleobases.c b/count_nucleobases.c
index 1b432da..d4dca06 100755
--- a/count_nucleobases.c
+++ b/count_nucleobases.c
@@ -4,24 +4,24 @@
#include <unistd.h>
#include <stdint.h>
#include <stdbool.h>
+#include <errno.h>
int main() {
size_t len = 0;
-
- unsigned long long counts[256] = {0};
+ unsigned long long counts[256] = {0};
char buffer[4096];
bool header = false;
- len = fread(&buffer, 1, 1, stdin);
+ len = fread(&buffer, 1, 1, stdin);
- if(len != NULL) {
+ if(errno) {
if(buffer[0] == '>') {
header = true;
- while((len = fread(&buffer, 1, 4096, stdin)) != NULL) {
+ while((len = fread(&buffer, 1, 4096, stdin)) != 0) {
unsigned int i = 0;
for(i = 0; i < len; i++) {
- if(buffer[i] == '>') {
+ if(buffer[i] == '>') {
header = true;
continue;
}
@@ -42,11 +42,11 @@ int main() {
exit(EXIT_FAILURE);
}
- printf("A:%llu\nC:%llu\nG:%llu\nT:%llu\n",
+ printf("A:%llu\nC:%llu\nG:%llu\nT:%llu\n",
counts['a'] + counts['A'],
counts['c'] + counts['C'],
counts['g'] + counts['G'],
counts['t'] + counts['T']);
- return EXIT_SUCCESS;
+ return EXIT_SUCCESS;
}