Krolyxon
Commit f94f903

Branches

Refs →

trossrcutils.c

26 lines · 528 B · C

1#include "utils.h"
2#include <stdio.h>
3
4void printarr(int a[], int n) {
5 for (int i = 0; i < n; i++) {
6 printf("%d ", a[i]);
7 }
8}
9
10void print_ascii(char *filename) {
11 char read_string[MAX_LEN];
12 FILE *fptr = NULL;
13 if ((fptr = fopen(filename, "r")) == NULL) {
14 fprintf(stderr, "error opening %s\n", filename);
15 }
16 while (fgets(read_string, sizeof(read_string), fptr) != NULL) {
17 printf("%s", read_string);
18 }
19 fclose(fptr);
20}
21
22void swap(int a[], int i, int j) {
23 int tmp = a[i];
24 a[i] = a[j];
25 a[j] = tmp;
26}