Skip to content

Instantly share code, notes, and snippets.

Last active January 19, 2021 22:52
  • 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/116dd414047c7c1d5901dc8af0dbf276 to your computer and use it in GitHub Desktop.
#include "stdio.h"
int main(void) {
float my_float_array[3]; // Once declared can only store 3 floats and will never change
my_float_array[0] = 1.4; // Adding each value one index at a time
my_float_array[1] = 2.5;
my_float_array[2] = 4.6;
int my_int_array[] = {1,2,3,4,5,6,7,8,9,10}; // Initialization holding 10 indicies or type int
char my_char_array[] = "Hi"; // A string is just a bunch of chars within an array
// the line below creates a char array in a different way. We are starting to let go of the CS50 idea of a string
char * my_string_array = "Goodbye"; // A char pointer points to the first element in the array like my_string_array[0]
printf("%.1f\n", my_float_array[1]);
printf("%i\n", my_int_array[9]);
printf("%c%c\n", my_char_array[0], my_char_array[1]);
printf("%c%c%c\n", my_string_array[4], my_string_array[5], my_string_array[6]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment