Student question: declare a struct called best_friend and initialize the members of best_friend based on the following information. Name: Jane Doe Phone Number: 377 177 377 Address: 1337 University Avenue

Question: declare a struct called best_friend and initialize the members of best_friend based on the following information. Name: Jane Doe Phone Number: 377 177 377 Address: 1337 University Avenue


Student question: Define a string literal called season that has the value "winter".

Question: Define a string literal called season that has the value "winter".


Student question: Define a stack-allocated string called holiday that has space for 20 characters including the null terminator. Set its initial value to "Valentine's Day".

Question: Define a stack-allocated string called holiday that has space for 20 characters including the null terminator. Set its initial value to "Valentine's Day".


Student question: Write a loop which traverses a linked list starting at front and prints the value of each node in the list. Separate each value with a space.

Question: Write a loop which traverses a linked list starting at front and prints the value of each node in the list. Separate each value with a space.


Goal: Set the value of delicious (which has already been declared) to "ice cream". | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char delicious[30]; // Submitted code below // Submitted code above /* hidden test code */ return 0; } // Submitted code below


Goal: Set the value of delicious (which has already been declared) to "ice cream". | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char delicious[30]; // Submitted code below delicious = "ice cream"; // Submitted code above /* hidden test code */ return 0; } // Submitted code below


Goal: Set the value of delicious (which has already been declared) to "ice cream". | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char delicious[30]; // Submitted code below *delicious = strcpy(delicious, "ice cream"); // Submitted code above /* hidden test code */ return 0; } // Submitted code below


Goal: Set the value of delicious (which has already been declared) to "ice cream". | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char delicious[30]; // Submitted code below delicious = strcpy(delicious, "ice cream"); // Submitted code above /* hidden test code */ return 0; } // Submitted code below


Student question: What will this declaration line become after the program has passed through the C pre-processor? | Code context (simplify for kids): #include <stdio.h> #define MAXNAME = 32; #declaration char name[MAXNAME]; int main() { #ifdef MACRO printf("%d\n", MACRO); #endif return 0; }

Question: What will this declaration line become after the program has passed through the C pre-processor?


Student question: Tell me about the C preprocessor

Question: Tell me about the C preprocessor


Student question: how can equality of two characters be verified?

Question: how can equality of two characters be verified?


Student question: how can a char be converted to an int?

Question: how can a char be converted to an int?


Code context (simplify for kids): int size = (int) argv[1];


Student question: How do I print the contents of a file line by line to standard output?

Question: How do I print the contents of a file line by line to standard output?


Goal: store up to n fibonacci numbers in a dynamically allocated array and print each element | Code context (simplify for kids): void fib(int** array, int n) { *array = malloc(sizeof(int) * n); int term1 = 0; int term2 = 1; int next; if (n == 1) { (*array)[0] = term1; } else if (n == 2) { (*array)[0] = term1; (*array)[1] = term2; } else { (*array)[0] = term1; (*array)[1] = term2; for (int i = 2; i < n; i++) { next = term1 + t


Student question: how do i truncate a string

Question: how do i truncate a string


Student question: what is wrong with my code? | Code context (simplify for kids): int strip_q_marks(char* s) { int count = 0; for (int i = strlen(s); i == 0; i--) { if (s[i - 1] == '?' && s[i] == '\0') { s[i - 1] = '\0'; count++; } } return count; }

Question: what is wrong with my code?


Student question: Use strcat to concatenate a space into a string

Question: Use strcat to concatenate a space into a string


Student question: how do I read an int from 4 bytes in a binary file

Question: how do I read an int from 4 bytes in a binary file


Goal: I want to read 4 byte integers from file metadata | Code context (simplify for kids): void read_bitmap_metadata(FILE *image, int *pixel_array_offset, int *width, int *height) { fseek(image, 9, SEEK_SET); fread(pixel_array_offset, 4, 1, image); fseek(image, 17, SEEK_SET); fread(width, 4, 1, image); fseek(image, 21, SEEK_SET); fread(height, 4, 1, image); }


Student question: I want to read integers from byte offsets 10-13, 18-21 and 22-25 | Code context (simplify for kids): void read_bitmap_metadata(FILE *image, int *pixel_array_offset, int *width, int *height) { fseek(image, 9, SEEK_SET); fread(pixel_array_offset, 4, 1, image); fseek(image, 17, SEEK_SET); fread(width, 4, 1, image); fseek(image, 21, SEEK_SET); fread(height, 4, 1, image); }

Question: I want to read integers from byte offsets 10-13, 18-21 and 22-25


Student question: initialize multiple pointers using a for loop

Question: initialize multiple pointers using a for loop


Student question: why is demo_user not defined? | Code context (simplify for kids): int main() { struct user demo_user; int result = create_user("Dario", &&demo_user); printf("%d\n", result); return 0; }

Question: why is demo_user not defined?


Student question: how do I insert an element into the first empty spot of an array?

Question: how do I insert an element into the first empty spot of an array?


Question: how to read ascii art


Student question: how to null terminate a string resulting from strncpy

Question: how to null terminate a string resulting from strncpy


Student question: how to use time function

Question: how to use time function


Student question: why do i get a warning for this code | Code context (simplify for kids): strcpy(new_post->contents, contents);

Question: why do i get a warning for this code


Student question: why do i get a maybe uninitialized warning | Code context (simplify for kids): strcpy(new_post->contents, contents);

Question: why do i get a maybe uninitialized warning


Student question: how do i malloc space for size 10 array

Question: how do i malloc space for size 10 array


Student question: how to access one char of a string when we have the pointer to that string only

Question: how to access one char of a string when we have the pointer to that string only


Student question: how can i fix the error in line 3 | Code context (simplify for kids): int test(char *a, char*b){ for(int i; i<9; i++){ if(*b[i] != "-" && *b[i] != *a[i]){ return 1; } } return 0; } int main(int argc, char** argv){ return test(argv[1], argv[2]); }

Question: how can i fix the error in line 3


Student question: how to pass command line arguements to another function one by one

Question: how to pass command line arguements to another function one by one


Student question: how to calculate the number of digits in an int

Question: how to calculate the number of digits in an int


Student question: how to perform integer division in c

Question: how to perform integer division in c


Question: what is 9/2 in c


Student question: how to get the number from i-th place in an integer

Question: how to get the number from i-th place in an integer


Student question: what is the output of this code | Code context (simplify for kids): #include <stdio.h> int main() { int number = 12345; int i; for (i = 0; i < 5; i++) { printf("%d", (number / (10^i)) % 10); } return 0; }

Question: what is the output of this code


Student question: what is the output when this code is run with arguements sin = 123456789 and sin_array is an integer array of 9 integers | Code context (simplify for kids): int populate_array(int sin, int *sin_array) { int number_of_digits = 0; while(sin != 0){ sin = sin / 10; number_of_digits ++; } if(number_of_digits != 9){ return 1; } else { for(int i = 0; i < 9; i++){ sin_array[i] = (sin / (10^(8 - i))) % 10; } } }

Question: what is the output when this code is run with arguements sin = 123456789 and sin_array is an integer array of 9 integers


Student question: what is the output when this code is run with arguements sin = 012345678 and sin_array is an integer array of 9 integers | Code context (simplify for kids): int populate_array(int sin, int *sin_array) { int number_of_digits = 0; while(sin != 0){ sin = sin / 10; number_of_digits ++; } if(number_of_digits != 9){ return 1; } else { for(int i = 0; i < 9; i++){ sin_array[i] = (sin / (10^(8 - i))) % 10; } } }

Question: what is the output when this code is run with arguements sin = 012345678 and sin_array is an integer array of 9 integers


Student question: how to get the i-th digit of a 2 digit number

Question: how to get the i-th digit of a 2 digit number


Student question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 6} | Code context (simplify for kids): int check_sin(int *sin_array) { int *mult_array = {1, 2, 1, 2, 1, 2, 1, 2, 1} int total = 0; for(int i = 0; i<9; i++){ int temp = sin_array[i] * mult_array[i] if(temp / 10 == 0){ total += temp; } else { int one = temp / 10; int two = temp % 10; total += (one * two); } } if(total % 10 == 0){ return 0

Question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 6}


Student question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7} | Code context (simplify for kids): int check_sin(int *sin_array) { int *mult_array = {1, 2, 1, 2, 1, 2, 1, 2, 1} int total = 0; for(int i = 0; i<9; i++){ int temp = sin_array[i] * mult_array[i] if(temp / 10 == 0){ total += temp; } else { int one = temp / 10; int two = temp % 10; total += (one * two); } } if(total % 10 == 0){ return 0

Question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7}


Student question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7} and the value of total | Code context (simplify for kids): int check_sin(int *sin_array) { int *mult_array = {1, 2, 1, 2, 1, 2, 1, 2, 1} int total = 0; for(int i = 0; i<9; i++){ int temp = sin_array[i] * mult_array[i] if(temp / 10 == 0){ total += temp; } else { int one = temp / 10; int two = temp % 10; total += (one * two); } } if(total % 10 == 0){ return 0

Question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7} and the value of total


Student question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 6} and the value of total | Code context (simplify for kids): int check_sin(int *sin_array) { int *mult_array = {1, 2, 1, 2, 1, 2, 1, 2, 1} int total = 0; for(int i = 0; i<9; i++){ int temp = sin_array[i] * mult_array[i] if(temp / 10 == 0){ total += temp; } else { int one = temp / 10; int two = temp % 10; total += (one * two); } } if(total % 10 == 0){ return 0

Question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 6} and the value of total


Student question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 6} and the value of total | Code context (simplify for kids): int check_sin(int *sin_array) { int *mult_array = {1, 2, 1, 2, 1, 2, 1, 2, 1} int total = 0; for(int i = 0; i<9; i++){ if((sin_array[i] * mult_array[i]) / 10 == 0){ total += (sin_array[i] * mult_array[i]); } else { int one = (sin_array[i] * mult_array[i]) / 10; int two = (sin_array[i] * mult_array[i

Question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 6} and the value of total


Student question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 6} and the value of total | Code context (simplify for kids): int check_sin(int *sin_array) { int *mult_array = {1, 2, 1, 2, 1, 2, 1, 2, 1} int total = 0; for(int i = 0; i<9; i++){ if((sin_array[i] * mult_array[i]) / 10 == 0){ total += (sin_array[i] * mult_array[i]); } else { int one = (sin_array[i] * mult_array[i]) / 10; int two = (sin_array[i] * mult_array[i

Question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 6} and the value of total


Student question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7} and the value of total | Code context (simplify for kids): int check_sin(int *sin_array) { int *mult_array = {1, 2, 1, 2, 1, 2, 1, 2, 1} int total = 0; for(int i = 0; i<9; i++){ if((sin_array[i] * mult_array[i]) / 10 == 0){ total += (sin_array[i] * mult_array[i]); } else { int one = (sin_array[i] * mult_array[i]) / 10; int two = (sin_array[i] * mult_array[i

Question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7} and the value of total


Code context (simplify for kids): int check_sin(int *sin_array) { int *mult_array = {1, 2, 1, 2, 1, 2, 1, 2, 1} int total = 0; for(int i = 0; i<9; i++){ if((sin_array[i] * mult_array[i]) / 10 == 0){ total += (sin_array[i] * mult_array[i]); } else { int one = (sin_array[i] * mult_array[i]) / 10; int two = (sin_array[i] * mult_array[i


Student question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7} and the value of total | Code context (simplify for kids): int check_sin(int *sin_array) { check_sin takes an array of integers as an argument int *mult_array = {1, 2, 1, 2, 1, 2, 1, 2, 1}; int total = 0; for(int i = 0; i<9; i++){ if((sin_array[i] * mult_array[i]) / 10 == 0){ total += (sin_array[i] * mult_array[i]); } else { int one = (sin_array[i] * mult_a

Question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7} and the value of total


Student question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7} and the value of total. can i track every step | Code context (simplify for kids): int check_sin(int *sin_array) { check_sin takes an array of integers as an argument int *mult_array = {1, 2, 1, 2, 1, 2, 1, 2, 1}; int total = 0; for(int i = 0; i<9; i++){ if((sin_array[i] * mult_array[i]) / 10 == 0){ total += (sin_array[i] * mult_array[i]); } else { int one = (sin_array[i] * mult_a

Question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7} and the value of total. can i track every step


Student question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7} and the value of total | Code context (simplify for kids): int check_sin(int *sin_array) { check_sin takes an array of integers as an argument int *mult_array = {1, 2, 1, 2, 1, 2, 1, 2, 1}; int total = 0; for(int i = 0; i<9; i++){ if((sin_array[i] * mult_array[i]) < 10 == 0){ total += (sin_array[i] * mult_array[i]); } else { int one = (sin_array[i] * mult_a

Question: what would the output be for sin_array = {8, 1, 0, 6, 2, 0, 7, 1, 7} and the value of total


Student question: how to initialize an array of integers in c

Question: how to initialize an array of integers in c


Student question: what does populating an integer array mean

Question: what does populating an integer array mean


Student question: how do i change a global array inside another function and retain the changes

Question: how do i change a global array inside another function and retain the changes


Student question: how to differentiate between files and directories

Question: how to differentiate between files and directories


Student question: how do i change sin_array initialisation or modification so the changes made to it in populate_array are global changes so i can use the modified sin_array in check_sin | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> // TODO: Implement populate_array /* * Convert a 9 digit int to a 9 element int array. */ int populate_array(int sin, int *sin_array) { int number_of_digits = 0; while(sin != 0){ sin = sin / 10; number_of_digits ++; } if(number_of_digits != 9){ return 1; } else

Question: how do i change sin_array initialisation or modification so the changes made to it in populate_array are global changes so i can use the modified sin_array in check_sin


Student question: what is the result of atoi("012345")

Question: what is the result of atoi("012345")


Student question: how to make a function take a non negative int as one parameter

Question: how to make a function take a non negative int as one parameter


Student question: how to check if a char is equal to a ?

Question: how to check if a char is equal to a ?


Student question: what is the value of greeting when the piece of code is run. | Code context (simplify for kids): char greeting[20]; strncpy(greeting, "Top of the morning to you", sizeof(greeting) - 1);

Question: what is the value of greeting when the piece of code is run.


Student question: what is the sizeof(greeting) | Code context (simplify for kids): char greeting[20]; strncpy(greeting, "Top of the morning to you", sizeof(greeting) - 1);

Question: what is the sizeof(greeting)


Student question: what is the value of greeting when the piece of code is run | Code context (simplify for kids): char greeting[20]; strncpy(greeting, "Top of the morning to you", 19);

Question: what is the value of greeting when the piece of code is run


Student question: how to store something read by fread() in a variable

Question: how to store something read by fread() in a variable


Student question: how to initialise space for 10 structs at once

Question: how to initialise space for 10 structs at once


Student question: how to find the length of a string in c

Question: how to find the length of a string in c


Student question: what is sizeof(Kaavya) | Code context (simplify for kids): char *name = "Kaavya"

Question: what is sizeof(Kaavya)


Student question: what is sizeof(name) | Code context (simplify for kids): char *name = "Kaavya"

Question: what is sizeof(name)


Student question: what is sizeof(*name) | Code context (simplify for kids): char *name = "Kaavya"

Question: what is sizeof(*name)


Student question: what is the output of sizeof(*name) | Code context (simplify for kids): char *name = "Kaavya"

Question: what is the output of sizeof(*name)


Student question: does something like strlen exist in c

Question: does something like strlen exist in c


Student question: what is strlen(name) | Code context (simplify for kids): char *name = "Kaavya"

Question: what is strlen(name)


Question: syntax of strcmp


Student question: how to check if a current item is the last node of a linked list in c

Question: how to check if a current item is the last node of a linked list in c


Student question: how to create an instance of am empty struct

Question: how to create an instance of am empty struct


Question: syntax of strcpy


Student question: how to cast datatypes in c

Question: how to cast datatypes in c


Student question: how to cast (const User *head) from a (const User *) to a (User *)

Question: how to cast (const User *head) from a (const User *) to a (User *)


Student question: usage of -> in structs

Question: usage of -> in structs


Student question: what is the syntax for calloc and an example

Question: what is the syntax for calloc and an example


Student question: is there an equivalent of count feature in C?

Question: is there an equivalent of count feature in C?


Student question: how to initialise a boolean value

Question: how to initialise a boolean value


Student question: when u initialise an array of pointers of length 32, what are all elements by default set to

Question: when u initialise an array of pointers of length 32, what are all elements by default set to


Student question: how to printf a combination of strings and variables

Question: how to printf a combination of strings and variables


Student question: how to read a ascii file

Question: how to read a ascii file


Student question: equivalent of break in c

Question: equivalent of break in c


Student question: how to set char *contents to char *contentt;

Question: how to set char *contents to char *contentt;


Student question: what is time(NULL) output

Question: what is time(NULL) output


Student question: what will be the output of ctime(time_address) | Code context (simplify for kids): time_t post_time = time(NULL); time_t *time_address = &post_time;

Question: what will be the output of ctime(time_address)


Student question: how to allocate space for time(NULL)

Question: how to allocate space for time(NULL)


Question: fscanf vs fgets


Student question: do you have to allocate memory for individual attributes of structs as well to avoid memory leak

Question: do you have to allocate memory for individual attributes of structs as well to avoid memory leak


Student question: how to allocate space for each item in struct | Code context (simplify for kids): typedef struct user { char name[MAX_NAME]; char profile_pic[MAX_NAME]; // This is a *filename*, not the file contents. struct post *first_post; struct user *friends[MAX_FRIENDS]; struct user *next; } User;

Question: how to allocate space for each item in struct


Student question: do i need to allocate space for every attribute separately even if i allocate space with sizeof(User) | Code context (simplify for kids): typedef struct user { char name[MAX_NAME]; char profile_pic[MAX_NAME]; // This is a *filename*, not the file contents. struct post *first_post; struct user *friends[MAX_FRIENDS]; struct user *next; } User;

Question: do i need to allocate space for every attribute separately even if i allocate space with sizeof(User)


Student question: do i have to free memory only when i malloc or in other cases too?

Question: do i have to free memory only when i malloc or in other cases too?


Student question: how to free a linked list example

Question: how to free a linked list example


Student question: how to free a calloc memory

Question: how to free a calloc memory


Student question: how to fix invalid reads

Question: how to fix invalid reads


Question: how does calloc work


Student question: how do i allocate space for each of the attributes of user | Code context (simplify for kids): typedef struct user { char name[MAX_NAME]; char profile_pic[MAX_NAME]; // This is a *filename*, not the file contents. struct post *first_post; struct user *friends[MAX_FRIENDS]; struct user *next; } User;

Question: how do i allocate space for each of the attributes of user


Student question: how to allocate space for an array of pointers to ints

Question: how to allocate space for an array of pointers to ints


Student question: syntax to calloc for a string

Question: syntax to calloc for a string


Student question: what is wrong with the memory allocations | Code context (simplify for kids): typedef struct user { char name[MAX_NAME]; char profile_pic[MAX_NAME]; // This is a *filename*, not the file contents. struct post *first_post; struct user *friends[MAX_FRIENDS]; struct user *next; } User; User *new_node = calloc(1, sizeof(User)); new_node->name = calloc(1, sizeof(char) * MAX_NAME);

Question: what is wrong with the memory allocations


Student question: how do i allocate space for this using calloc | Code context (simplify for kids): char *a[32];

Question: how do i allocate space for this using calloc


Student question: do i need to close the file here? if yes, where all do i need to close the file | Code context (simplify for kids): int update_pic(User *user, const char *filename) { if(strlen(filename) >= MAX_NAME){ return 2; } else if((fopen(filename, "r")) == NULL){ return 1; } else { strcpy(user->profile_pic, filename); return 0; } }

Question: do i need to close the file here? if yes, where all do i need to close the file


Student question: how to set a string attribute of a struct to null

Question: how to set a string attribute of a struct to null


Question: does "" mean NULL


Student question: how to initialise an array of 32 NULL

Question: how to initialise an array of 32 NULL


Student question: how to set a string to NULL

Question: how to set a string to NULL


Student question: is a == NULL? | Code context (simplify for kids): char *a = '\0'

Question: is a == NULL?


Student question: how to close the file in this | Code context (simplify for kids): int update_pic(User *user, const char *filename) { if(strlen(filename) >= MAX_NAME){ return 2; } else if((fopen(filename, "r")) == NULL){ return 1; } else { strcpy(user->profile_pic, filename); return 0; } }

Question: how to close the file in this


Goal: i want to close the file | Code context (simplify for kids): int update_pic(User *user, const char *filename) { if(strlen(filename) >= MAX_NAME){ return 2; } else if((fopen(filename, "r")) == NULL){ return 1; } else { strcpy(user->profile_pic, filename); return 0; } }


Question: what is fclose(fp)


Student question: tons of valgrind error makes valgrind stuck and does not show me heap summary. what to do.

Question: tons of valgrind error makes valgrind stuck and does not show me heap summary. what to do.


Student question: how to use gdb to debug

Question: how to use gdb to debug


Student question: when i intialise char *profile, what is its default value set to

Question: when i intialise char *profile, what is its default value set to


Student question: how to check if malloc fails

Question: how to check if malloc fails


Question: what is memset


Student question: c_helper.py:125: in _t stdout, stderr, returncode = self._run_exec(args=args, input_=input_, timeout=timeout) c_helper.py:85: in _run_exec return _exec([os.path.join(".", self.executable_name)] + (args or []), **kwargs) c_helper.py:471: in _exec stdout, stderr = proc.communicate(timeout=timeout, input=input_) /local/packages/python-3.10/lib/python3.10/subprocess.py:1152: in communicate stdout, std

Question: c_helper.py:125: in _t stdout, stderr, returncode = self._run_exec(args=args, input_=input_, timeout=timeout) c_helper.py:85: in _run_exec return _exec([os.path.join(".", self.executable_name)] + (args or []), **kwargs) c_helper.py:471: in _exec stdout, stderr = proc.communicate(timeout=timeout, input=input_) /local/packages/python-3.10/lib/python3.10/subprocess.py:1152: in communicate stdout, std


Student question: strncpy(char *dest, "ananyajain", 7) output?

Question: strncpy(char *dest, "ananyajain", 7) output?


Student question: what is the output of the code | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> // Initialize two parallel lists. void initialize(int *a1, int *a2, int n) { for (int i = 0; i < n; i++) { a1[i] = i; a2[i] = i; } } int main() { int numbers1[3]; int *numbers2 = malloc(sizeof(int) * 3); initialize(numbers1, numbers2, 3); for (int i = 0; i < 3;

Question: what is the output of the code


Student question: what exactly is the second parameter of strtol

Question: what exactly is the second parameter of strtol


Student question: what is strlen(a) | Code context (simplify for kids): char *a = "Hello I"

Question: what is strlen(a)


Student question: is strlen(a) 7 or 8 or 9

Question: is strlen(a) 7 or 8 or 9


Student question: is strlen(a) 7 or 8 or 9 | Code context (simplify for kids): char *a = "Hello I"

Question: is strlen(a) 7 or 8 or 9


Student question: what is strlen(a) when char *a = "Hello I"

Question: what is strlen(a) when char *a = "Hello I"


Student question: what will be the output | Code context (simplify for kids): char *a = "Hello Bruh" char *b = strchr(a, ' ') printf("%s", b)

Question: what will be the output


Student question: output | Code context (simplify for kids): char *a = "Hello Bruh" char *b = strchr(a, ' ') - 1 printf("%s", b)

Question: output


Student question: output | Code context (simplify for kids): char *a = "Hello Bruh" char *b = strchr(a, ' ') - 2 printf("%s", b)

Question: output


Question: how does grep work


Question: how does cut work


Student question: my child calls a different program using execl which has different exit values. how do i get the exit value the program exited with back to my child

Question: my child calls a different program using execl which has different exit values. how do i get the exit value the program exited with back to my child


Student question: how to write "swim" to stdin

Question: how to write "swim" to stdin


Student question: a program called validate is expecting 2 inputs from stdin. my function calls validate using execl. how do i pass the variables i need to as stdin to it.

Question: a program called validate is expecting 2 inputs from stdin. my function calls validate using execl. how do i pass the variables i need to as stdin to it.


Student question: what is the difference between exit(0) and return 0

Question: what is the difference between exit(0) and return 0


Question: how does strtok work


Student question: Let a string be s = "main : linked_list.o main.o". What is the output of strtok(s, " ")

Question: Let a string be s = "main : linked_list.o main.o". What is the output of strtok(s, " ")


Student question: how to check is a string starts with \t

Question: how to check is a string starts with \t


Student question: what is the value of b | Code context (simplify for kids): a = "\tHello World" b = strncmp(a, "\t", 1);

Question: what is the value of b


Student question: what is the value of token | Code context (simplify for kids): char *a = "\tHello Boss" char *token = strtok(a, " ")

Question: what is the value of token


Student question: what does strncmp returning 3 mean

Question: what does strncmp returning 3 mean


Student question: how to find if a char is in a string

Question: how to find if a char is in a string


Student question: what is the value of a[0] | Code context (simplify for kids): char *a = "Hello I am Kaavya";

Question: what is the value of a[0]


Question: how does stat work?


Student question: how to use access to check if a file exists or not

Question: how to use access to check if a file exists or not


Student question: how to check if a string is NULL

Question: how to check if a string is NULL


Student question: what is return value of args_to_string({"Hi" , "Kaavya" , NULL}, a, 3 | Code context (simplify for kids): char *args_to_string(char **args, char *buffer, int size) { buffer[0] = '\0'; int i = 0; while (args[i] != NULL) { strncat(buffer, args[i], size - strlen(buffer)); strncat(buffer, " ", size - strlen(buffer)); i++; } return buffer; } char *a = malloc(256);

Question: what is return value of args_to_string({"Hi" , "Kaavya" , NULL}, a, 3


Student question: what is return value of args_to_string({"Hi" , "Kaavya" , NULL}, a, 256) | Code context (simplify for kids): char *args_to_string(char **args, char *buffer, int size) { buffer[0] = '\0'; int i = 0; while (args[i] != NULL) { strncat(buffer, args[i], size - strlen(buffer)); strncat(buffer, " ", size - strlen(buffer)); i++; } return buffer; } char *a = malloc(256);

Question: what is return value of args_to_string({"Hi" , "Kaavya" , NULL}, a, 256)


Student question: how to update the updated time of a file

Question: how to update the updated time of a file


Student question: Can you use variables declared in the main stack directly in a function and change its value globally (variable of type int)

Question: Can you use variables declared in the main stack directly in a function and change its value globally (variable of type int)


Student question: how to mention the start and end numbers for random()

Question: how to mention the start and end numbers for random()


Student question: how to use random() to generate numbers between 0 to 99 inclusive in C

Question: how to use random() to generate numbers between 0 to 99 inclusive in C


Task: how to use random() to generate numbers between 0 to 99 inclusive in C


Student question: what is a[2] | Code context (simplify for kids): char *a = "Hello"

Question: what is a[2]


Student question: area=`expr $width * $height` why is this incorrect

Question: area=`expr $width * $height` why is this incorrect


Student question: does the given code work | Code context (simplify for kids): char *a; a = "Hello";

Question: does the given code work


Student question: How do I reassign a string in C

Question: How do I reassign a string in C


Student question: How do I read a file through stdin in C

Question: How do I read a file through stdin in C


Student question: How do I use scanf to read a redirected file

Question: How do I use scanf to read a redirected file


Student question: How do I use a function in one C file in another C file

Question: How do I use a function in one C file in another C file


Student question: How to convert char to int

Question: How to convert char to int


Student question: split string on spaces

Question: split string on spaces


Student question: how do i read a file line by line

Question: how do i read a file line by line


Student question: read character by character in a string

Question: read character by character in a string


Student question: does fgets overwrite the string array

Question: does fgets overwrite the string array


Question: dictionaries in C


Student question: count number of spaces in string

Question: count number of spaces in string


Student question: how to read the last string in a string delimeted by a delimeter using strtok

Question: how to read the last string in a string delimeted by a delimeter using strtok


Student question: strtok doesnt work as expected, last string in line cannot be obtained | Code context (simplify for kids): //get the target name targets = strtok(line, " "); printf("%s \n", targets); //create the Rule datatype if (curr_rule == NULL){ curr_rule = malloc(sizeof(Rule)); head = curr_rule; }else{ Rule * new_rule = malloc(sizeof(Rule)); (curr_rule -> next_rule) = new_rule; curr_rule = new_rule; } curr_rule ->

Question: strtok doesnt work as expected, last string in line cannot be obtained


Code context (simplify for kids): //get the target name targets = strtok(line, " "); printf("%s \n", targets); //create the Rule datatype if (curr_rule == NULL){ curr_rule = malloc(sizeof(Rule)); head = curr_rule; }else{ Rule * new_rule = malloc(sizeof(Rule)); (curr_rule -> next_rule) = new_rule; curr_rule = new_rule; } curr_rule ->


Student question: skip the first character in a string literal

Question: skip the first character in a string literal


Question: print a char** array


Student question: how does recursion work in C?

Question: how does recursion work in C?


Student question: how do i make my function wait on a recursive call without using fork in C?

Question: how do i make my function wait on a recursive call without using fork in C?


Student question: how do i use random in C? it says it need RAND_MAX, how do i set it myself?

Question: how do i use random in C? it says it need RAND_MAX, how do i set it myself?


Student question: not reading binary file correctly. giving me random values. | Code context (simplify for kids): #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <unistd.h> #define MESSAGE "%ld reads were done in %ld seconds.\n" long num_reads, seconds; int main(int argc, char **argv) { if (argc != 3) { fprintf(stderr, "Usage: time_reads s filename\n"); exit(1); } secon

Question: not reading binary file correctly. giving me random values.


Student question: I am unable to use asprintf, eventhough i have defined _GNU_SOURCE and imported stdio.h

Question: I am unable to use asprintf, eventhough i have defined _GNU_SOURCE and imported stdio.h


Student question: Is the function strcpy safe?

Question: Is the function strcpy safe?


Student question: How to copy a string to an array of char in C safely?

Question: How to copy a string to an array of char in C safely?


Code context (simplify for kids): hile (scanf(" %c %s %*d %*s %*s %d %*s %*d %*s %*s", &file_type, permissions, &file_size) != EOF) {


Code context (simplify for kids): while (scanf(" %c %s %*d %*s %*s %d %*s %*d %*s %*s", &file_type, permissions, &file_size) != EOF) {scanf(" %s %d ", temp_s, &temp_i); while (scanf(" %c %s %*d %*s %*s %d %*s %*d %*s %*s ", &file_type, permissions, &file_size) != EOF) { if (file_type == '-' && file_size > cutoff_size) { if (argc ==


Code context (simplify for kids): while (scanf(" %c %s %*d %*s %*s %d %*s %*d %*s %*s ", &file_type, permissions, &file_size) != EOF) { if (file_type == '-' && file_size > cutoff_size) { if (argc == 2){ count_so_far++; } else { if (check_permissions(permissions, argv[2]) == 0) { count_so_far++; } } } }


Student question: why should I put a space after the last %*s | Code context (simplify for kids): while (scanf(" %c %s %*d %*s %*s %d %*s %*d %*s %*s ", &file_type, permissions, &file_size) != EOF) { if (file_type == '-' && file_size > cutoff_size) { if (argc == 2){ count_so_far++; } else { if (check_permissions(permissions, argv[2]) == 0) { count_so_far++; } } } }

Question: why should I put a space after the last %*s


Code context (simplify for kids): int age[5] = {4, 70, 52, 18, 16}; int *p = age;


Student question: Why is phone used instead of &phone? | Code context (simplify for kids): char phone[11]; scanf("%s %d", phone, &index);

Question: Why is phone used instead of &phone?


Goal: get string input and store it in phone. | Code context (simplify for kids): char phone[11]; scanf("%s %d", &phone);


Student question: why is system("ls -l") of type int?

Question: why is system("ls -l") of type int?


Student question: does scanf read multiple lines?

Question: does scanf read multiple lines?


Student question: how do I only print certain part of stdin? | Code context (simplify for kids): int main(int argc, char** argv) { if (!(argc == 2 || argc == 3)) { fprintf(stderr, "USAGE: count_large size [permissions]\n"); return 1; } if (argc == 2) { char line[32]; while (fgets(line, 32, stdin) != NULL) { printf("%s", line); } } return 0; }

Question: how do I only print certain part of stdin?


Student question: how do i parse stdin without strtok? | Code context (simplify for kids): int main(int argc, char** argv) { if (!(argc == 2 || argc == 3)) { fprintf(stderr, "USAGE: count_large size [permissions]\n"); return 1; } if (argc == 2) { char line[32]; while (fgets(line, 32, stdin) != NULL) { printf("%s", line); } } return 0; }

Question: how do i parse stdin without strtok?


Student question: how do i parse stdin with strtol? | Code context (simplify for kids): int main(int argc, char** argv) { if (!(argc == 2 || argc == 3)) { fprintf(stderr, "USAGE: count_large size [permissions]\n"); return 1; } if (argc == 2) { char line[32]; while (fgets(line, 32, stdin) != NULL) { printf("%s", line); } } return 0; }

Question: how do i parse stdin with strtol?


Student question: inputs of scanf? | Code context (simplify for kids): int main(int argc, char** argv) { if (!(argc == 2 || argc == 3)) { fprintf(stderr, "USAGE: count_large size [permissions]\n"); return 1; } if (argc == 2) { char line[32]; while (fgets(line, 32, stdin) != NULL) { printf("%s", line); } } return 0; }

Question: inputs of scanf?


Student question: if my stdin is "hello yo 3 191 so what" what are my scanf arguments?

Question: if my stdin is "hello yo 3 191 so what" what are my scanf arguments?


Student question: if my stdin is "-rwxrwxrwx 1 kimluci2 kimluci2 763 Jan 22 18:05 Makefile" what are my scanf arguments?

Question: if my stdin is "-rwxrwxrwx 1 kimluci2 kimluci2 763 Jan 22 18:05 Makefile" what are my scanf arguments?


Student question: how do i skip the first line of stdin when scanf?

Question: how do i skip the first line of stdin when scanf?


Student question: what is the type of %c%10s

Question: what is the type of %c%10s


Student question: how do i initialize a variable of %c%10s

Question: how do i initialize a variable of %c%10s


Student question: is %c variable declared as char

Question: is %c variable declared as char


Student question: what does EOF do | Code context (simplify for kids): int main(int argc, char** argv) { if (!(argc == 2 || argc == 3)) { fprintf(stderr, "USAGE: count_large size [permissions]\n"); return 1; } // TODO: Process command line arguments. if (argc == 2) { int total = 0; char dir; char perms[10]; int size; int param1 = strtol(argv[1], NULL, 10); while (scanf

Question: what does EOF do


Student question: what does == 3 in the while loop do | Code context (simplify for kids): int main(int argc, char** argv) { if (!(argc == 2 || argc == 3)) { fprintf(stderr, "USAGE: count_large size [permissions]\n"); return 1; } // TODO: Process command line arguments. if (argc == 2) { int total = 0; char dir; char perms[10]; int size; int param1 = strtol(argv[1], NULL, 10); while (scanf

Question: what does == 3 in the while loop do


Student question: how do i make scanf ignore the first line?

Question: how do i make scanf ignore the first line?


Student question: how do i make scanf skip a specific line? | Code context (simplify for kids): int main(int argc, char** argv) { if (!(argc == 2 || argc == 3)) { fprintf(stderr, "USAGE: count_large size [permissions]\n"); return 1; } // TODO: Process command line arguments. if (argc == 2) { int total = 0; char dir; char perms[10]; int size; int param1 = strtol(argv[1], NULL, 10); while (scanf

Question: how do i make scanf skip a specific line?


Student question: %*[^\n] what does ths do

Question: %*[^\n] what does ths do


Student question: how do i ONLY skip the first line from stdin?? | Code context (simplify for kids): int main(int argc, char** argv) { if (!(argc == 2 || argc == 3)) { fprintf(stderr, "USAGE: count_large size [permissions]\n"); return 1; } // TODO: Process command line arguments. if (argc == 2) { int total = 0; char dir; char perms[10]; int size; int param1 = strtol(argv[1], NULL, 10); while (scanf

Question: how do i ONLY skip the first line from stdin??


Student question: why is (dir == "-") giving me errors? | Code context (simplify for kids): int main(int argc, char** argv) { if (!(argc == 2 || argc == 3)) { fprintf(stderr, "USAGE: count_large size [permissions]\n"); return 1; } // TODO: Process command line arguments. if (argc == 2) { int total = 0; char dir; char perms[10]; int size; int param1 = strtol(argv[1], NULL, 10); scanf("%*[^\

Question: why is (dir == "-") giving me errors?


Student question: how to check a given integer is 9 digits using % 10 or / 10

Question: how to check a given integer is 9 digits using % 10 or / 10


Student question: what does this return | Code context (simplify for kids): int help = 100000000 % 10; printf("%d", help);

Question: what does this return


Student question: what does this return | Code context (simplify for kids): int help = 100923999 % 10; printf("%d", help);

Question: what does this return


Student question: how do i check that a given integer is 9 digits?

Question: how do i check that a given integer is 9 digits?


Student question: how do i check that a given integer is 9 digits with math operations?

Question: how do i check that a given integer is 9 digits with math operations?


Student question: how do i use % 10 and / 10 to calculate the digits?

Question: how do i use % 10 and / 10 to calculate the digits?


Student question: how do i populate an array with a given integer?

Question: how do i populate an array with a given integer?


Student question: how do i separate an integer 123 to array [1,2,3]

Question: how do i separate an integer 123 to array [1,2,3]


Student question: how to check how many digits an integer has

Question: how to check how many digits an integer has


Question: if i % 2 == 1


Student question: what does this print | Code context (simplify for kids): printf(2 / 10);

Question: what does this print


Student question: waht does this print | Code context (simplify for kids): int i = 2/10; printf("%d", i);

Question: waht does this print


Student question: what does this print | Code context (simplify for kids): int i = 12/10; printf("%d", i);

Question: what does this print


Student question: how to check if integer is divisible by 10

Question: how to check if integer is divisible by 10


Student question: how do i get the length of all argv

Question: how do i get the length of all argv


Code context (simplify for kids): int c = 6/2; printf("%d", c);


Student question: what does this print? | Code context (simplify for kids): int c = 6/2; printf("%d", c);

Question: what does this print?


Student question: how do i pass in an array of argv elements

Question: how do i pass in an array of argv elements


Student question: how do i get all argv and pass it in an array to helper method

Question: how do i get all argv and pass it in an array to helper method


Student question: how do i build an array from argv inputs?

Question: how do i build an array from argv inputs?


Student question: how do you loop through the argv elements

Question: how do you loop through the argv elements


Student question: what does this print | Code context (simplify for kids): int c = 3/2; printf("%d", c);

Question: what does this print


Student question: how do you do ceiling?

Question: how do you do ceiling?


Student question: how do you do ceiling without importing libraries??????

Question: how do you do ceiling without importing libraries??????


Student question: how do i make this return 2 | Code context (simplify for kids): int c = 3/2; printf("%d", c);

Question: how do i make this return 2


Student question: what does this return | Code context (simplify for kids): int c = 3/2.0; printf("%d", c);

Question: what does this return


Student question: what does this return? | Code context (simplify for kids): int c; c = (int) 3/2; printf("%d", c);

Question: what does this return?


Student question: what doe sthis return | Code context (simplify for kids): int c = (3 / 2) + ((3 % 2) != 0); printf("%d", c);

Question: what doe sthis return


Student question: what does this return? | Code context (simplify for kids): int c = (4 / 2) + ((4 % 2) != 0); printf("%d", c);

Question: what does this return?


Student question: rwjat does this reutn | Code context (simplify for kids): int c = int((4 / 2) + ((4 % 2) != 0)); printf("%d", c);

Question: rwjat does this reutn


Student question: waht does this reutnr? | Code context (simplify for kids): int c = (4 / 2) + ((4 % 2) != 0); printf("%d", c);

Question: waht does this reutnr?


Student question: what does this print? | Code context (simplify for kids): int c; printf("%d", c+1);

Question: what does this print?


Student question: what is the value of c+1? | Code context (simplify for kids): int c; printf("%d", c+1);

Question: what is the value of c+1?


Student question: what is c=+1? | Code context (simplify for kids): int c; printf("%d", c=+1);

Question: what is c=+1?


Student question: what is the value of c? | Code context (simplify for kids): int c; c+=1;

Question: what is the value of c?


Student question: what is the value of c? | Code context (simplify for kids): int c=0; c+=1;

Question: what is the value of c?


Goal: print Same if the 2 arguments are the same. | Code context (simplify for kids): int main(int argc, char **argv) { if (argc != 3) { printf("Invalid\n"); } else { if (s1 == s2) { printf("Same\n"); } else { printf("Different\n"); } } return 0; }


Goal: compare argv[1] to argv[2] without using strcmp | Code context (simplify for kids): int main(int argc, char **argv) { if (argc != 3) { printf("Invalid\n"); } else { if (argv[1] == argv[2]) { printf("Same\n"); } else { printf("Different\n"); } } return 0; }


Goal: how do i concatenate a space after copying hi to greeting? | Code context (simplify for kids): int main(int argc, char **argv) { if (argc != 3) { fprintf(stderr, "Usage: greeting message name\n"); return 1; } char greeting[20]; char *name = argv[2]; // Your code goes here char *hi = argv[1]; strncpy(greeting, hi, sizeof(greeting) - 1); strncat(greeting, ' ', sizeof(greeting) - strlen(greeting


Goal: how do i make sure greeting is properly null terminated after strncpy call? | Code context (simplify for kids): int main(int argc, char **argv) { if (argc != 3) { fprintf(stderr, "Usage: greeting message name\n"); return 1; } char greeting[20]; char *name = argv[2]; // Your code goes here char *hi = argv[1]; strncpy(greeting, hi, sizeof(greeting) - 1); strncat(greeting, " ", sizeof(greeting) - strlen(greeting


Student question: how do you remove the last few question marks from a given string?

Question: how do you remove the last few question marks from a given string?


Goal: if p-s-1 != "?" return 0, else return the value | Code context (simplify for kids): int strip_q_marks(char *s) { char *p; p = strchr(s, '\0'); if (s[p-s-1] != "?") { return 0; } else { printf("%d\n", p-s-1); } }


Goal: change s to be s of length at most n | Code context (simplify for kids): int truncate(char *s, int n) { int p = strlen(s); if (p <= n) { return 0; } else { strncpy(s, s, n); int q = strlen(s); return p - q; } }


Goal: modify s to a string with max character of n in line 7. | Code context (simplify for kids): int truncate(char *s, int n) { int p = strlen(s); if (p <= n) { return 0; } else { strncpy(s, s, n); s[n+1] = '\0'; int q = strlen(s); return p - q; } }


Student question: Does fseek in c take in bits or bytes for offset?

Question: Does fseek in c take in bits or bytes for offset?


Student question: does fread take in bytes as element size?

Question: does fread take in bytes as element size?


Student question: When you fseek with pointer by 0 distance with respect to end of file what value do you print?

Question: When you fseek with pointer by 0 distance with respect to end of file what value do you print?


Student question: how many characters does this have? | Code context (simplify for kids): "Someone over there is calling you. we are going for work. take care of yourself."

Question: how many characters does this have?


Goal: Why do i get this error? assignment to ‘int *’ from ‘size_t’ {aka ‘long unsigned int’} makes pointer from integer without a cast [-Wint-conversion] 13 | pixel_array_offset = fread(&pointer, 4, 1, image); | Code context (simplify for kids): void read_bitmap_metadata(FILE *image, int *pixel_array_offset, int *width, int *height) { int pointer; pointer = fseek(image, 10, SEEK_SET); pixel_array_offset = fread(&pointer, 4, 1, image); pointer = fseek(image, 18, SEEK_SET); width = fread(&pointer, 4, 1, image); pointer = fseek(image, 22, SEEK


Goal: why does this not free the memory i used for pixels? | Code context (simplify for kids): for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { free(pixels[i][j]); } } free(pixels);


Student question: why would you pass in User **user_ptr_add here | Code context (simplify for kids): /* * Create a new user with the given name. Insert it at the tail of the list * of users whose head is pointed to by *user_ptr_add. * * Return: * - 0 if successful * - 1 if a user by this name already exists in this list * - 2 if the given name cannot fit in the 'name' array * (don't forget about th

Question: why would you pass in User **user_ptr_add here


Student question: why is user_ptr_add passed in as a pointer to a pointer | Code context (simplify for kids): int create_user(const char *name, User **user_ptr_add) { User *curr = user_ptr_add; while (curr->next != NULL) { curr = curr->next } return -1; }

Question: why is user_ptr_add passed in as a pointer to a pointer


Goal: traverse through the Users until it reaches the end | Code context (simplify for kids): int create_user(const char *name, User **user_ptr_add) { User *curr = user_ptr_add; while (curr->next != NULL) { curr = curr->next } return -1; }


Student question: what happens when you make a struct with members and don't initialize all its contents?

Question: what happens when you make a struct with members and don't initialize all its contents?


Student question: how do you do "pass" in c

Question: how do you do "pass" in c


Student question: is this the right way to return 1 if the file does not exist or cannot be opened? | Code context (simplify for kids): int update_pic(User *user, const char *filename) { // file cannot be opened FILE *file = fopen(filename, "rb"); if (file == NULL) { return 2; } return -1; }

Question: is this the right way to return 1 if the file does not exist or cannot be opened?


Student question: does this return 2 if the file does not exist or cannot be opened? | Code context (simplify for kids): int update_pic(User *user, const char *filename) { // file cannot be opened FILE *file = fopen(filename, "rb"); if (file == NULL) { return 2; } return -1; }

Question: does this return 2 if the file does not exist or cannot be opened?


Goal: how do i return 1 if the two users are already friends? | Code context (simplify for kids): int make_friends(const char *name1, const char *name2, User *head) { User *curr1 = head; User *curr2 = head; User *store1 = NULL; User *store2 = NULL; while (curr1 != NULL) { if (strcmp(curr1->name, name1) == 0) { store1 = curr1; } else { curr1 = curr1->next; } } while (curr2 != NULL) { if (strcmp(c


Code context (simplify for kids): int make_friends(const char *name1, const char *name2, User *head) { User *curr1 = head; User *curr2 = head; User *store1 = NULL; User *store2 = NULL; while (curr1 != NULL) { if (strcmp(curr1->name, name1) == 0) { store1 = curr1; } else { curr1 = curr1->next; } } while (curr2 != NULL) { if (strcmp(c


Student question: how do you write file to standard output?

Question: how do you write file to standard output?


Goal: make 2 valid users friends if they are not already friends | Code context (simplify for kids): int make_friends(const char *name1, const char *name2, User *head) { User *curr1 = head; User *curr2 = head; while (curr1 != NULL && strcmp(curr1->name, name1) != 0) { curr1 = curr1->next; } while (curr2 != NULL && strcmp(curr2->name, name2) != 0) { curr2 = curr2->next; } if (curr1 == NULL || curr2


Student question: gives a nice human-readable representation of the date and time of each post in the format, "Friday Jan 27 23:01:00 2023". Use the time and ctime functions to find the current time and convert a time value to a string, respectively.

Question: gives a nice human-readable representation of the date and time of each post in the format, "Friday Jan 27 23:01:00 2023". Use the time and ctime functions to find the current time and convert a time value to a string, respectively.


Student question: how do i use ctime to convert this into a string? | Code context (simplify for kids): time_t current_time = time(NULL);

Question: how do i use ctime to convert this into a string?


Student question: What is the line to compile it into an executable named a.out that it will print the value 5 to stdout? (You do not need to include the options to display warnings, build the symbol table for the debugger or select the C standard.) | Code context (simplify for kids): #include <stdio.h> int main() { #ifdef MACRO printf("%d\n", MACRO); #endif return 0; }

Question: What is the line to compile it into an executable named a.out that it will print the value 5 to stdout? (You do not need to include the options to display warnings, build the symbol table for the debugger or select the C standard.)


Code context (simplify for kids): #define MAXNAME = 32; and then the declaration char name[MAXNAME];


Student question: in the program. What will this declaration line become after the program has passed through the C pre-processor? | Code context (simplify for kids): #define MAXNAME = 32; and then the declaration char name[MAXNAME];

Question: in the program. What will this declaration line become after the program has passed through the C pre-processor?


Student question: What will be the output of the following program fragment? | Code context (simplify for kids): #define SUPERVISOR(regular) regular + 5 int main() { int regular_pay = 20; int hours_worked = 10; printf("pay is %d\n", (hours_worked * SUPERVISOR(regular_pay))); // rest omitted }

Question: What will be the output of the following program fragment?


Student question: What is the line to compile it into an executable named a.out that it will print the value 5 to stdout? | Code context (simplify for kids): #include <stdio.h> int main() { #ifdef MACRO printf("%d\n", MACRO); #endif return 0; }

Question: What is the line to compile it into an executable named a.out that it will print the value 5 to stdout?


Student question: how to you hard code strncpy?

Question: how to you hard code strncpy?


Student question: what does this print? | Code context (simplify for kids): src = "abcdefghijklmno" strncpy(dest, src, 10); dest[9] = '\0'; printf("%s", dest);

Question: what does this print?


Student question: does dest have a null terminator | Code context (simplify for kids): src = "abcdefghijklmno" strncpy(dest, src, 10); dest[9] = '\0'; printf("%s", dest);

Question: does dest have a null terminator


Student question: what does this print | Code context (simplify for kids): src = "abcdefghijklmno" strncpy(dest, src, 10); dest[7] = '\0'; printf("%s", dest);

Question: what does this print


Code context (simplify for kids): #include <stdio.h> #define SIZE 4 #define OVERFLOW 4 int main() { int index = 0; int i; int before[SIZE] = {10, 10, 10, 10}; int a[SIZE] = {0, 0, 0, 0}; int after[SIZE] = {10, 10, 10, 10}; printf("Address of the variables:\n"); for (index = 0; index < SIZE; index++) { printf("%lx -> &after[%d]\n", (


Student question: what does this print? | Code context (simplify for kids): #include <stdio.h> #define SIZE 4 #define OVERFLOW 4 int main() { int index = 0; int i; int before[SIZE] = {10, 10, 10, 10}; int a[SIZE] = {0, 0, 0, 0}; int after[SIZE] = {10, 10, 10, 10}; printf("Address of the variables:\n"); for (index = 0; index < SIZE; index++) { printf("%lx -> &after[%d]\n", (

Question: what does this print?


Student question: if i set the middle of a char array to '\0', would the values after it become null values as well

Question: if i set the middle of a char array to '\0', would the values after it become null values as well


Student question: if i have char *s with size 10 and s[6] is originally 'a', then make s[5]='\0', what would s[6] be

Question: if i have char *s with size 10 and s[6] is originally 'a', then make s[5]='\0', what would s[6] be


Student question: What are all possible combinations that the output can be | Code context (simplify for kids): #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main() { int ret; printf("A\n"); ret = fork(); printf("B\n"); if (ret < 0) { perror("fork"); exit(1); } else if (ret == 0) { printf("C\n"); } else { printf("D\n"); } printf("E\n"); return 0; }

Question: What are all possible combinations that the output can be


Student question: can the output be something other than A B D E B C E | Code context (simplify for kids): #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main() { int ret; printf("A\n"); ret = fork(); printf("B\n"); if (ret < 0) { perror("fork"); exit(1); } else if (ret == 0) { printf("C\n"); } else { printf("D\n"); } printf("E\n"); return 0; }

Question: can the output be something other than A B D E B C E


Student question: how do i modify the program so that each process creates exactly one a new process? | Code context (simplify for kids): #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "Usage: forkloop <iterations>\n"); exit(1); } int iterations = strtol(argv[1], NULL, 10); for (int i = 0; i < iterations; i++) { int n = fork(); if (n < 0) { perror("fork");

Question: how do i modify the program so that each process creates exactly one a new process?


Goal: modify the program so that each process creates exactly one a new process. | Code context (simplify for kids): #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "Usage: forkloop <iterations>\n"); exit(1); } int iterations = strtol(argv[1], NULL, 10); for (int i = 0; i < iterations; i++) { int n = fork(); if (n < 0) { perror("fork");


Goal: how do you add an if statement that checks if the process is a child | Code context (simplify for kids): #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "Usage: forkloop <iterations>\n"); exit(1); } int iterations = strtol(argv[1], NULL, 10); for (int i = 0; i < iterations; i++) { int n = fork(); if (n < 0) { perror("fork");


Student question: how do you check if a line from fgets starts with a tab?

Question: how do you check if a line from fgets starts with a tab?


Student question: what is line[0] from this? | Code context (simplify for kids): char line[50]; line = " hello";

Question: what is line[0] from this?


Student question: what is line[0] from this? | Code context (simplify for kids): char line[50]; strcpy(line, " hello");

Question: what is line[0] from this?


Student question: what does this return | Code context (simplify for kids): char line[50]; strcpy(line, " hello"); if (line[0] == "\t") { printf("yay"); }

Question: what does this return


Student question: what does this return | Code context (simplify for kids): char line[50]; strcpy(line, " hello"); if (line[0] == \t) { printf("yay"); }

Question: what does this return


Code context (simplify for kids): char *args_to_string(char **args, char *buffer, int size) { buffer[0] = '\0'; int i = 0; while (args[i] != NULL) { strncat(buffer, args[i], size - strlen(buffer)); strncat(buffer, " ", size - strlen(buffer)); i++; } return buffer; }


Student question: explain how fseek works

Question: explain how fseek works


Student question: is there a difference between exit(0) and return 0 from main in C

Question: is there a difference between exit(0) and return 0 from main in C


Student question: how do i free malloced memory

Question: how do i free malloced memory


Student question: explain the C dup2 function

Question: explain the C dup2 function


Student question: Why does my truncate function not change s | Code context (simplify for kids): #include <stdlib.h> #include <stdio.h> #include <string.h> /* Write a function named truncate() that takes a string s and a non-negative integer n. If s has more than n characters (not including the null terminator), the function should truncate s at n characters and return the number of characters

Question: Why does my truncate function not change s


Student question: How do I change the value of s | Code context (simplify for kids): #include <stdlib.h> #include <stdio.h> #include <string.h> /* Write a function named truncate() that takes a string s and a non-negative integer n. If s has more than n characters (not including the null terminator), the function should truncate s at n characters and return the number of characters

Question: How do I change the value of s


Student question: How do I create the function truncate from the information in lines 6 to 12 | Code context (simplify for kids): #include <stdlib.h> #include <stdio.h> #include <string.h> /* Write a function named truncate() that takes a string s and a non-negative integer n. If s has more than n characters (not including the null terminator), the function should truncate s at n characters and return the number of characters

Question: How do I create the function truncate from the information in lines 6 to 12


Student question: How do I change s in truncate to a different string | Code context (simplify for kids): #include <stdlib.h> #include <stdio.h> #include <string.h> /* Write a function named truncate() that takes a string s and a non-negative integer n. If s has more than n characters (not including the null terminator), the function should truncate s at n characters and return the number of characters

Question: How do I change s in truncate to a different string


Goal: Write a function named truncate() that takes a string s and a non-negative integer n. If s has more than n characters (not including the null terminator), the function should truncate s at n characters and return the number of characters that were removed. If s has n or fewer characters, s is unchanged and the function returns 0. For example, if s is the string "function" and n is 3, then truncate | Code context (simplify for kids): #include <stdlib.h> #include <stdio.h> #include <string.h> /* Write a function named truncate() that takes a string s and a non-negative integer n. If s has more than n characters (not including the null terminator), the function should truncate s at n characters and return the number of characters


Student question: What is wrong with my code | Code context (simplify for kids): int make_friends(const char *name1, const char *name2, User *head) { User user1 = NULL; User user2 = NULL; while(head != NULL){ if (strcmp(name1, head->name) == 0){ user1 = *head; } else if (strcmp(name2, head->name) == 0){ user2 = *head; } else{ head = head->next; } } if ((user1 == NULL) || (user2

Question: What is wrong with my code


Student question: What's wrong with my code | Code context (simplify for kids): int make_friends(const char *name1, const char *name2, User *head) { User *user1 = NULL; User *user2 = NULL; while(head != NULL){ if (strcmp(name1, head->name) == 0){ user1 = head; } else if (strcmp(name2, head->name) == 0){ user2 = head; } else{ head = head->next; } } if ((user1 == NULL) || (user2

Question: What's wrong with my code


Student question: What's wrong with my code | Code context (simplify for kids): int make_friends(const char *name1, const char *name2, User *head) { User *user1 = NULL; User *user2 = NULL; while(head != NULL){ if (strcmp(name1, head->name) == 0){ user1 = head; } else if (strcmp(name2, head->name) == 0){ user2 = head; } else{ head = head->next; } } if ((user1 == NULL) || (user2

Question: What's wrong with my code


Student question: What does my code print | Code context (simplify for kids): #define SUPERVISOR(regular) regular + 5 int main() { int regular_pay = 20; int hours_worked = 10; printf("pay is %d\n", (hours_worked * SUPERVISOR(regular_pay))); }

Question: What does my code print


Student question: Why am I getting a warning when I try to wait for the child process to finish (line 24) | Code context (simplify for kids): #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "Usage: forkloop <iterations>\n"); exit(1); } int iterations = strtol(argv[1], NULL, 10); int pid = getpid(); for (int i = 0; i < iterations; i++) { int n = fork(); if (n < 0

Question: Why am I getting a warning when I try to wait for the child process to finish (line 24)


Student question: what should I put in the parameter of wait so that the child process finishes first (line 24) | Code context (simplify for kids): #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "Usage: forkloop <iterations>\n"); exit(1); } int iterations = strtol(argv[1], NULL, 10); int pid = getpid(); for (int i = 0; i < iterations; i++) { int n = fork(); if (n < 0

Question: what should I put in the parameter of wait so that the child process finishes first (line 24)


Student question: how to initialize the pointer allocated to point to heap-allocated space for an entire row of pixel data.

Question: how to initialize the pointer allocated to point to heap-allocated space for an entire row of pixel data.


Goal: byte 10 - 13 should be the value for pixel_array_offset, byte 18 - 21 should be the value for width and byte 22-25 should be the height. | Code context (simplify for kids): void read_bitmap_metadata(FILE *image, int *pixel_array_offset, int *width, int *height) { fseek(image, 10, SEEK_SET); error = fread(pixel_array_offset,4,1,image); fseek(image, 18, SEEK_SET); error = fread(width,4,1,image); fseek(image, 22, SEEK_SET); error = fread(height,4,1,image); }


Goal: pixel_array_offset should assign the value in byte 10 - 13 of the file, byte 18 - 21 should be the value for width should be assigned the value of byte 18 - 21 of the file, height should be assign the value of byte 22-25 of the file | Code context (simplify for kids): void read_bitmap_metadata(FILE *image, int *pixel_array_offset, int *width, int *height) { fseek(image, 10, SEEK_SET); error = fread(pixel_array_offset,4,1,image); fseek(image, 18, SEEK_SET); error = fread(width,4,1,image); fseek(image, 22, SEEK_SET); error = fread(height,4,1,image); }


Goal: assign arg[v] to cmd_permission | Code context (simplify for kids): char cmd_permission[10]; cmd_permission = argv[2];


Student question: how to assign string to char array

Question: how to assign string to char array


Student question: assign string to char array without strcpy()

Question: assign string to char array without strcpy()


Goal: initialize an array with height elements | Code context (simplify for kids): struct pixel **read_pixel_array(FILE *image, int pixel_array_offset, int width, int height) { struct pixel *pixel_arr[height]; }


Student question: how to use gdb with multiple files

Question: how to use gdb with multiple files


Question: how to use gdb


Student question: how to run next line in gdb

Question: how to run next line in gdb


Student question: what does fopen() return if file does not exist?

Question: what does fopen() return if file does not exist?


Student question: how to go back in gdp?

Question: how to go back in gdp?


Student question: can i pass a User * type into a const User * type?

Question: can i pass a User * type into a const User * type?


Student question: can you negative index an array?

Question: can you negative index an array?


Student question: can you initialise an array of 0 elements?

Question: can you initialise an array of 0 elements?


Student question: how can i set all elements of an array to NULL?

Question: how can i set all elements of an array to NULL?


Student question: how to run until breakpoint in gdb?

Question: how to run until breakpoint in gdb?


Student question: can i set a string to NULL?

Question: can i set a string to NULL?


Student question: ho to print contents of a text file with fopen?

Question: ho to print contents of a text file with fopen?


Student question: do you have to fclose on a NULL stream?

Question: do you have to fclose on a NULL stream?


Question: fgets return value?


Student question: how to define char array in function parameter?

Question: how to define char array in function parameter?


Question: how to use ctime?


Goal: assign the pointer value to time(NULL) | Code context (simplify for kids): *curr_time = time(NULL);


Student question: does fgets() read empty lines?

Question: does fgets() read empty lines?


Student question: what is the purpose of NULL passed to execl()?

Question: what is the purpose of NULL passed to execl()?


Student question: how to write multiple values to a pipe?

Question: how to write multiple values to a pipe?


Student question: how can i use strtok() to split on spaces and tabs?

Question: how can i use strtok() to split on spaces and tabs?


Student question: how to use strtok() to find comments?

Question: how to use strtok() to find comments?


Student question: can i index a char *pointer?

Question: can i index a char *pointer?


Student question: does fgets() read \n character for blank lines?

Question: does fgets() read \n character for blank lines?


Student question: how can i tell if a string starts with a \t tab character?

Question: how can i tell if a string starts with a \t tab character?


Student question: can you compare characters with == ?

Question: can you compare characters with == ?


Student question: can i set a struct attribute to a read-only string in a helper function?

Question: can i set a struct attribute to a read-only string in a helper function?


Student question: when should i malloc a string vs just assign it in a helper function?

Question: when should i malloc a string vs just assign it in a helper function?


Student question: how to call strtok repeatedly on the same line?

Question: how to call strtok repeatedly on the same line?


Student question: is there a function to count the number of words in a string?

Question: is there a function to count the number of words in a string?


Student question: can you initailize an array of size 0?

Question: can you initailize an array of size 0?


Student question: what is returned if strtok() is called on a whitespace line?

Question: what is returned if strtok() is called on a whitespace line?


Student question: how to strip a string of specific characters?

Question: how to strip a string of specific characters?


Student question: does strtok remove tabs when passed " "?

Question: does strtok remove tabs when passed " "?


Student question: what's the \r character?

Question: what's the \r character?


Student question: what happens if you call strtok() with NULL?

Question: what happens if you call strtok() with NULL?


Student question: how to strip \n character with gets?

Question: how to strip \n character with gets?


Student question: how to strip \n character with fgets?

Question: how to strip \n character with fgets?


Question: when does strtok end?


Student question: does strncpy copy the null terminator?

Question: does strncpy copy the null terminator?


Student question: how to edit value of a dynamically allocated string?

Question: how to edit value of a dynamically allocated string?


Student question: how to get the size of an array?

Question: how to get the size of an array?


Student question: what type does malloc(sizeof(char *)) return?

Question: what type does malloc(sizeof(char *)) return?


Student question: can i check if a variables been declaared or not?

Question: can i check if a variables been declaared or not?


Student question: how to use strchr to replace a character with another?

Question: how to use strchr to replace a character with another?


Student question: replace \r character with \0 | Code context (simplify for kids): if ((newline_index = strchr(curr_line, '\r')) != NULL) { *newline_index = '\0'; }

Question: replace \r character with \0


Student question: how to clear a character array?

Question: how to clear a character array?


Student question: can you set a character array to NULL?

Question: can you set a character array to NULL?


Student question: how to write ineteger to a binary file?

Question: how to write ineteger to a binary file?


Student question: can i use % string formating in a write() call?

Question: can i use % string formating in a write() call?


Student question: what is the first argument passed to select()?

Question: what is the first argument passed to select()?


Student question: how to check if a pointer points to NULL?

Question: how to check if a pointer points to NULL?


Student question: how to malloc an int for a struct

Question: how to malloc an int for a struct


Student question: will this code safely allocate an int on the heap? | Code context (simplify for kids): int *ptr = malloc(sizeof(int)); int num = 42; *ptr = num;

Question: will this code safely allocate an int on the heap?


Student question: how to use write to write to a buffer string?

Question: how to use write to write to a buffer string?


Student question: when do you have to close a fd?

Question: when do you have to close a fd?


Student question: does this properly set buf to an empty string? | Code context (simplify for kids): char buf[5]; buf = {'/0'};

Question: does this properly set buf to an empty string?


Student question: Why is it that if I sigint at position A, the process is terminated? I didn't call quit in the handler function | Code context (simplify for kids): int x = 5; void handler(int sig) { x += 3; fprintf(stderr, "inside %d ", x); } int main() { fprintf(stderr, "start "); struct sigaction act; act.sa_handler = handler; act.sa_flags = 0; sigemptyset(&act.sa_mask); sigaction(SIGINT, &act, NULL); x += 2; fprintf(stderr, "outside %d", x); return 0; }

Question: Why is it that if I sigint at position A, the process is terminated? I didn't call quit in the handler function


Student question: A signal handling function that you write must always have the same signature.Why is this true?

Question: A signal handling function that you write must always have the same signature.Why is this true?


Goal: Set the time of the post to the current time using time() | Code context (simplify for kids): int make_post(const User *author, User *target, char *contents) { // check if users exist if (author == NULL || target == NULL){ return 2; } // check if they are friends int isFriend = 0; for (int i = 0; i < MAX_FRIENDS; i++){ if (author->friends[i] == target){ isFriend = 1; break; } } if (isFriend


Goal: Print user profile and any associated posts. However the time is not printed properly. | Code context (simplify for kids): int print_user(const User *user) { if (user == NULL){ return 1; } printf("------------------------------------------\n"); printf("Posts:\n"); // print posts Post* currPost = user->first_post; while (currPost != NULL){ printf("From: %s\n", currPost->author); printf("Date: %s\n", ctime(currPost->date)


Student question: the time is not printed properly from line 71 | Code context (simplify for kids): int make_post(const User *author, User *target, char *contents) { // check if users exist if (author == NULL || target == NULL){ return 2; } // check if they are friends int isFriend = 0; for (int i = 0; i < MAX_FRIENDS; i++){ if (author->friends[i] == target){ isFriend = 1; break; } } if (isFriend

Question: the time is not printed properly from line 71


Goal: /* * Make two users friends with each other. This is symmetric - a pointer to * each user must be stored in the 'friends' array of the other. * * New friends must be added in the first empty spot in the 'friends' array. * * Return: * - 0 on success. * - 1 if the two users are already friends. * - 2 if the users are not already friends, but at least one already has * MAX_FRIENDS friends. * - 3 if t | Code context (simplify for kids): int make_friends(const char *name1, const char *name2, User *head) { User* curr1 = find_user(name1, head); User* curr2 = find_user(name2, head); // check if user exists if (curr1 == NULL || curr2 == NULL){ return 4; } // check if the same user is passed in twice if (curr1 == curr2){ return 3; } // c


Student question: This code recursively evaluates rules by comparing the most recent modification time. | Code context (simplify for kids): void evaluate_rule(Rule *rule, struct stat *parent_stat){ // given some conditions, execute action of the rule (compares dependencies) struct stat rule_stat; stat(rule->target, &rule_stat); Dependency *cur_dep = rule->dependencies; if(cur_dep != NULL){ // recursively call on dependency rules while(c

Question: This code recursively evaluates rules by comparing the most recent modification time.


Task: I want to write code that recursively calls the function through a linked list structure with each node being its own linked list. For each function call, I want to call a helper function: evaluate(Node).


Task: Write function: Evaluate. This function traverses a linked list with linked list nodes and recursively calls the function. The base case prints the value at the node.


Student question: How do I print an emoji to stdout?

Question: How do I print an emoji to stdout?


Task: Implement a max-heap data structure


Student question: How do you read a string from stdin using scanf?

Question: How do you read a string from stdin using scanf?


Question: What does %10s do?


Student question: What is the type for a pointer to a struct?

Question: What is the type for a pointer to a struct?


Task: I want to take a string like "main : dep1 dep2" and split it into the two strings "main" and "dep1 dep2"


Student question: How can you use strtok to handle multiple delimiter characters?

Question: How can you use strtok to handle multiple delimiter characters?


Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char str_to_delim[] = "name : dep1 dep2"; strtok(str_to_delim, " :"); return 0; }


Student question: how do I get the size of an array that's passed into the main function

Question: how do I get the size of an array that's passed into the main function


Student question: how do you get the size of **argv

Question: how do you get the size of **argv


Student question: How do you get the size of **argv that's passed into main

Question: How do you get the size of **argv that's passed into main


Student question: How do I use command line from within a program

Question: How do I use command line from within a program


Student question: What is the variable type of system("ls -l")

Question: What is the variable type of system("ls -l")


Student question: Do I use char** to hold the information of system("ls -l")

Question: Do I use char** to hold the information of system("ls -l")


Student question: Do I call scanf for each line that directed to it from the shell

Question: Do I call scanf for each line that directed to it from the shell


Goal: Supposed to take in a single line of input with 9 different variables and print the 5th one | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char s[10]; char idk[31]; char username[31]; char groupname[31]; int size; char month[3]; char date[3]; char time[6]; char filename[31]; scanf("%10s %31s %31s %31s %d %3s %3s %6s %31s", s, idk, username, groupname, &size, month, date, time, filename


Goal: Supposed to take in a single line of input with 9 different variables and print the 5th one | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char s[10]; char idk[31]; char username[31]; char groupname[31]; int size; char month[3]; char date[3]; char time[6]; char filename[31]; scanf("%9s %30s %30s %30s %d %2s %2s %5s %30s", s, idk, username, groupname, &size, month, date, time, filename)


Goal: Supposed to take in a single line of input with 9 different variables and print the 5th one (which is an integer) | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char s[10]; char idk[31]; char username[31]; char groupname[31]; int size; char month[3]; char date[3]; char time[6]; char filename[31]; scanf("%9s %30s %30s %30s %d %2s %2s %5s %30s", s, idk, username, groupname, &size, month, date, time, filename)


Student question: Why is it printing a random number instead of the number I inputted | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char s[10]; char idk[31]; char username[31]; char groupname[31]; int size; char month[3]; char date[3]; char time[6]; char filename[31]; scanf("%9s %30s %30s %30s %d %2s %2s %5s %30s", s, idk, username, groupname, &size, month, date, time, filename)

Question: Why is it printing a random number instead of the number I inputted


Student question: Why is printf printing a random number when scanf sets the number before the printf function | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char s[10]; char idk[31]; char username[31]; char groupname[31]; int size; char month[3]; char date[3]; char time[6]; char filename[31]; scanf("%9s %30s %30s %30s %d %2s %2s %5s %30s", s, idk, username, groupname, &size, month, date, time, filename)

Question: Why is printf printing a random number when scanf sets the number before the printf function


Student question: Why is printf printing a 0 when scanf should change size before the printf function | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char s[10]; char idk[31]; char username[31]; char groupname[31]; int size; char month[3]; char date[3]; char time[6]; char filename[31]; size = 0; scanf("%9s %30s %30s %30s %d %2s %2s %5s %30s", s, idk, username, groupname, &size, month, date, time,

Question: Why is printf printing a 0 when scanf should change size before the printf function


Student question: If we are inputting a file into a program from shell, can we tell how many lines are in the file

Question: If we are inputting a file into a program from shell, can we tell how many lines are in the file


Student question: How do I take a subsection of a string

Question: How do I take a subsection of a string


Student question: Can I split an input into two variables if there is no space between them

Question: Can I split an input into two variables if there is no space between them


Student question: Can I split the input of a string into two by using %c first and then %8s

Question: Can I split the input of a string into two by using %c first and then %8s


Goal: Code is supposed to take 4 strings and an int. The first string will be split into two with directory taking the first character of the string and then permissions taking the other 9 characters. The printf will print directory, permissions and size to make sure the first string was split properly and the integer was also taken correctly. | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char groupname[31]; int size; size = 0; scanf("%c %8s %30s %30s %30s %d", directory, permissions, idk, username, groupname, &size); printf("%c %8s %d \n", directory, permissions,


Student question: Does char name[10] specify a string that's 10 characters long or 9 characters long

Question: Does char name[10] specify a string that's 10 characters long or 9 characters long


Goal: Code is supposed to take 4 strings and an int. The first string will be split into two with directory taking the first character of the string and then permissions taking the other 9 characters. The printf will print directory, permissions and size to make sure the first string was split properly and the integer was also taken correctly. | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char groupname[31]; int size; size = 0; scanf("%c %9s %31s %31s %31s %d", &directory, permissions, idk, username, groupname, &size); printf("%c %9s %d \n", directory, permissions,


Student question: Why do I get the message "zsh: abort ./testing" after the proper output when the input is "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char groupname[31]; int size; size = 0; scanf("%c %9s %31s %31s %31s %d", &directory, permissions, idk, username, groupname, &size); printf("%c %9s %d \n", directory, permissions,

Question: Why do I get the message "zsh: abort ./testing" after the proper output when the input is "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog"


Student question: Why do I get the message: "- rwx------ 1734 zsh: abort ./testing" When the input is "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char groupname[31]; int size; size = 0; scanf("%c %9s %31s %31s %31s %d", &directory, permissions, idk, username, groupname, &size); printf("%c %9s %d \n", directory, permissions,

Question: Why do I get the message: "- rwx------ 1734 zsh: abort ./testing" When the input is "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog"


Goal: Code is supposed to take 7 strings and 2 ints. The first string will be split into two with directory taking the first character of the string and then permissions taking the other 9 characters. The printf will print the variables. | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char groupname[31]; int size; char month[3]; int date; char time[5]; char filename[31]; size = 0; scanf(" %c %9s %31s %31s %31s %d %3s %d %5s %31s", &directory, permissions, idk,


Student question: Why does this input "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog", give this output "- rwx------ 1 reid staff 1536 Jun 0 14:52 prog zsh: abort ./testing" | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char group_name[31]; int size; char month[3]; int date; char time[5]; char filename[31]; size = 0; scanf(" %c %9s %31s %31s %31s %d %3s %d %5s %31s", &directory, permissions, idk,

Question: Why does this input "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog", give this output "- rwx------ 1 reid staff 1536 Jun 0 14:52 prog zsh: abort ./testing"


Student question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" give the correct characters and strings in the printf but wrong ints | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char group_name[31]; int size; char month[3]; int date; char time[5]; char filename[31]; size = 0; scanf("%c %s %s %s %s %d %s %d %s %s", &directory, permissions, idk, username, g

Question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" give the correct characters and strings in the printf but wrong ints


Student question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" give the correct characters and strings in the printf but size = 1536 and date = 0 | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char group_name[31]; int size; char month[3]; int date; char time[5]; char filename[31]; size = 0; scanf("%c %s %s %s %s %d %s %d %s %s", &directory, permissions, idk, username, g

Question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" give the correct characters and strings in the printf but size = 1536 and date = 0


Goal: Code is supposed to take 9 strings. The first string will be split into two with directory taking the first character of the string and then permissions taking the other 9 characters. Then s_size will be converted into an integer. Then all the variables except s_size are printed | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char group_name[31]; char s_size[31]; char month[3]; char date[2]; char time[5]; char filename[31]; scanf("%c %s %s %s %s %s %s %s %s %s", &directory, permissions, idk, username,


Goal: Code is supposed to take 9 strings. The first string is 10 characters long and will be split into two with directory taking the first character of the string and then permissions taking the other 9 characters. Then s_size will be converted into an integer. Then all the variables except s_size are printed | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char group_name[31]; char s_size[31]; char month[3]; char date[2]; char time[5]; char filename[31]; scanf("%c %s %s %s %s %s %s %s %s %s", &directory, permissions, idk, username,


Student question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" give the error of "zsh: abort" | Code context (simplify for kids): -rwx------ 1 reid staff 1734 Jun 22 14:52 prog

Question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" give the error of "zsh: abort"


Student question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" give the error of "zsh: abort" | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char group_name[31]; char s_size[31]; char month[31]; char date[31]; char time[31]; char filename[31]; scanf(" %c %s %s %s %s %s %s %s %s %s", &directory, permissions, idk, userna

Question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" give the error of "zsh: abort"


Student question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" give the error of "zsh: abort" | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char group_name[31]; char s_size[31]; char month[31]; char date[31]; char time[31]; char filename[31]; scanf("%c%s %s %s %s %s %s %s %s %s", &directory, permissions, idk, username

Question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" give the error of "zsh: abort"


Student question: How do I get the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" to not give the error of "zsh: abort" | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char group_name[31]; char s_size[31]; char month[31]; char date[31]; char time[31]; char filename[31]; scanf("%c%s %s %s %s %s %s %s %s %s", &directory, permissions, idk, username

Question: How do I get the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" to not give the error of "zsh: abort"


Student question: How do I get the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" to not give the error of "zsh: abort" | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char group_name[31]; char s_size[31]; char month[31]; char date[31]; char time[31]; char filename[31]; scanf("%c %s %s %s %s %s %s %s %s %s", &directory, permissions, idk, usernam

Question: How do I get the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog" to not give the error of "zsh: abort"


Student question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog", give correct print statement, but still give an error after | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char group_name[31]; char s_size[31]; char month[31]; char date[31]; char time[31]; char filename[31]; scanf("%c %s %s %s %s %s %s %s %s %s", &directory, permissions, idk, usernam

Question: Why does the input of "-rwx------ 1 reid staff 1734 Jun 22 14:52 prog", give correct print statement, but still give an error after


Goal: Code is supposed to take 9 strings. The first string is 10 characters long and will be split into two with directory taking the first character of the string and then permissions taking the other 9 characters. Then s_size will be converted into an integer. Then all the variables except s_size are printed | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(){ char directory; char permissions[9]; char idk[31]; char username[31]; char group_name[31]; char s_size[31]; char month[31]; char date[31]; char time[31]; char filename[31]; scanf("%c %s %s %s %s %s %s %s %s %s", &directory, permissions, idk, usernam


Goal: The main takes in a number and potentially a string in argv. min_size is supposed to be the number given in argv. Then, a "ls -l" of the current directory is given as the input. The first line is supposed to be skipped as it does not match the form of the listed files. The size of the file is first taken as a string, and then converted to an int. If the size of the file is greater than min_size, t | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { if (!(argc == 2 || argc == 3)) { fprintf(stderr, "USAGE: count_large size [permissions]\n"); return 1; } int min_size = strtol(argv[1], NULL, 10); int num_filtered_files = 0; int eof = 1; int first = 0; char directory; char per


Goal: The main takes in a number and potentially a string in argv. min_size is supposed to be the number given in argv. Then, a "ls -l" of the current directory is given as the input. The first line is supposed to be skipped as it does not match the form of the listed files. The size of the file is first taken as a string, and then converted to an int. If the size of the file is greater than min_size, t | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int check_permissions(char *given, char *needed){ int same = 0; for(int i = 0; i < 9; i++){ if(needed[i] != '-'){ if(needed[i] != given[i]){ same = 1; break; } } } return same; } int main(int argc, char** argv) { if (!(argc == 2 || argc == 3)) { fprintf(stderr,


Task: given an int, and an empty int array, convert each digit into a single place in the int array


Student question: How do I use modulo to get the individual digits of an int

Question: How do I use modulo to get the individual digits of an int


Student question: If I give a helper function an empty array, how do I keep the changes to the array in main without returning the array

Question: If I give a helper function an empty array, how do I keep the changes to the array in main without returning the array


Student question: If I give the address of an int array to helper function, what should the argument for the helper function be.

Question: If I give the address of an int array to helper function, what should the argument for the helper function be.


Student question: Is it possible to keep the value of an int array that is edited in a helper function if the helper function's argument is also int array, and it doesn't return the array?

Question: Is it possible to keep the value of an int array that is edited in a helper function if the helper function's argument is also int array, and it doesn't return the array?


Goal: Populate the empty integer array in a helper function, and return whether the given int was 9 digits long. In the main function print the digits in the now populated array and whether the given number was 9 digits long | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int t_populate_array(int sin, int *sin_array) { for (int i = 8; -1 < i; i--){ sin_array[i] = sin % 10; if(sin == 0){ return 1; } sin = sin / 10; } return 0; } int main() { int sin_arrayy[9]; int sin = 999999999; int valid = t_populate_array(sin, &sin_arrayy); f


Goal: Populate the empty integer array in a helper function, and return whether the given int was 9 digits long. In the main function print the digits in the now populated array and whether the given number was 9 digits long by either printing 0 or 1 | Code context (simplify for kids): #include <stdio.h> #include <stdlib.h> int t_populate_array(int sin, int *sin_array) { for (int i = 8; -1 < i; i--){ sin_array[i] = sin % 10; if(sin == 0){ return 1; } sin = sin / 10; } return 0; } int main() { int sin_arrayy[9]; int sin = 999999999; int valid = t_populate_array(sin, sin_arrayy); fo