#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