Skip to content

Instantly share code, notes, and snippets.

@sojohnnysaid
Created February 11, 2018 20:27
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sojohnnysaid/509643aa4fa493d37adbbf7b866cf011 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <cs50.h>
#include <string.h>
int main(void)
{
// use printf to type out each character of the user's name
// separate with pipes to represent each character taking up
// some space in memory
string name = get_string("enter your name: ");
printf("characters: ");
// output each character of the user's name
for (int i = 0; i < strlen(name); i++)
{
printf("| %c ", name[i]);
}
printf("|\n");
// output the integer value that maps to the ascii character
printf("integers: ");
for (int i = 0; i < strlen(name); i++)
{
printf("| %d ", name[i]);
}
printf("|\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment