Skip to content

Instantly share code, notes, and snippets.

@NotaPhysicist
Created December 11, 2019 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NotaPhysicist/38a424f9b8c1026a308cb5a0a925495d to your computer and use it in GitHub Desktop.
Save NotaPhysicist/38a424f9b8c1026a308cb5a0a925495d to your computer and use it in GitHub Desktop.
Playing around with printing a grid of characters using for loops and putchar() and passing arguments in functions.
/**
* putchar.c -- playing around with printng a grid of characters using
* for loops and putchar and passing arguments in functions
*/
#include <stdio.h>
#include <stdlib.h>
void printchar(char ch, int rows, int cols);
int main(void)
{
char ch = '+';
int rows = 5;
int cols = 5;
printchar(ch, rows, cols);
return EXIT_SUCCESS;
}
void printchar(char ch, int rows, int cols)
{
int i, j;
for (i = 0; i < rows; i++)
{
for (j = 0; j < cols; j++)
{
putchar(ch);
}
putchar('\n');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment