Skip to content

Instantly share code, notes, and snippets.

View sqroot3's full-sized avatar

Matias L. sqroot3

  • USA
View GitHub Profile
@sqroot3
sqroot3 / linefold.c
Last active May 10, 2018 23:41
linefold.c - program that folds long input lines into shorter lines after first nonwhitespace character
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
// Write a program to fold long input lines into 2 shorter lines
// after first nonblank character. Take care of very long lines,
// and if there's no blanks/tabs before column
// Essentially a string tokenizer
int length(char input[]);
@sqroot3
sqroot3 / charcount.c
Last active April 15, 2018 18:49
charcount.c - prints histogram of frequencies of different characters in input (only printing visible ones)
#include <stdio.h>
/*
Author: Matias Lago
Objective: Print histogram of frequencies of different characters in input (will only print visible ones)
*/
#define STARTING_CHARACTER ' '
#define ENDING_CHARACTER '~'
@sqroot3
sqroot3 / entab.c
Last active February 16, 2018 13:12
entab.c - Program that replaces a string of blanks by the min # of spaces & tabs required to generate identical output
#include <stdio.h>
#define TABSIZE 8
int main()
{
int c, nchars, nspaces;
//nchars = number of chars, nspaces = number of spaces
nchars = nspaces = 0;