user_id
stringlengths
24
24
time
stringlengths
24
24
feature_type
stringclasses
5 values
feature_version
stringclasses
2 values
input_question
stringlengths
1
1.24k
input_code
stringlengths
2
18.5k
input_intention
stringlengths
1
2.48k
input_task_description
stringlengths
18
3.32k
63c6481a5f004bf4898cf973
2023-02-03T23:45:17.440Z
General Question
v1
If a function is given a string, can you directly edit the string in the function or do you need to use malloc
null
null
null
63c6481a5f004bf4898cf973
2023-02-04T00:20:22.976Z
General Question
v1
Does strcpy also copy the null terminator
null
null
null
63c6481a5f004bf4898cf973
2023-02-04T00:39:24.555Z
General Question
v1
Can I use strcat with a string and a character
null
null
null
63c6481a5f004bf4898cf973
2023-02-14T00:33:36.738Z
General Question
v1
Can you use memset to set characters to null pointer
null
null
null
63c6481a5f004bf4898cf973
2023-02-14T00:43:42.177Z
General Question
v1
How do I use malloc on a char * given to the function. How do I then assign characters to that char *.
null
null
null
63c6481a5f004bf4898cf973
2023-02-14T00:55:13.333Z
General Question
v1
If I'm given a char * in a function, how do I make the changes stay outsides the function
null
null
null
63c6481a5f004bf4898cf973
2023-02-14T00:58:40.846Z
General Question
v1
If the parameter to my function is char *, how do I make changes to the variable that will stay in main.
null
null
null
63c6481a5f004bf4898cf973
2023-02-14T01:07:25.998Z
Help Fix Code
v1
null
char *copy(char *dest, const char *src, int capacity) { dest = malloc(sizeof(char) * capacity); memset(dest, '\0', capacity); for(int i = 0; i < (capacity - 1); i++){ dest[i] = src[i]; } return dest; }
char *copy copies the string in *src to *dest, but it makes sure that *dest ends with a '\0'. capacity is supposed to be the maximum amount of characters copied to *dest, including the '\0' at the end.
null
63c6481a5f004bf4898cf973
2023-02-14T01:08:29.695Z
Help Fix Code
v1
null
char *copy(char *dest, const char *src, int capacity) { dest = malloc(sizeof(char) * capacity); memset(dest, '\0', capacity); dest[capacity] = '\0'; for(int i = 0; i < (capacity - 1); i++){ dest[i] = src[i]; } return dest; }
char *copy copies the string in *src to *dest, but it makes sure that *dest ends with a '\0'. capacity is supposed to be the maximum amount of characters copied to *dest, including the '\0' at the end.
null
63c6481a5f004bf4898cf973
2023-02-14T01:09:03.999Z
Question from Code
v1
Why don't my changes to dest remain in main?
char *copy(char *dest, const char *src, int capacity) { dest = malloc(sizeof(char) * capacity); memset(dest, '\0', capacity); for(int i = 0; i < (capacity - 1); i++){ dest[i] = src[i]; } return dest; }
null
null
63c6481a5f004bf4898cf973
2023-02-14T01:09:57.539Z
Question from Code
v1
How do I make changes to dest remain in main
char *copy(char *dest, const char *src, int capacity) { dest = malloc(sizeof(char) * capacity); memset(dest, '\0', capacity); for(int i = 0; i < (capacity - 1); i++){ dest[i] = src[i]; } return dest; }
null
null
63c6481a5f004bf4898cf973
2023-02-14T01:21:24.171Z
General Question
v1
Do you need to use malloc when changing the values of an array in a function
null
null
null
63c6481a5f004bf4898cf973
2023-02-14T18:54:50.942Z
General Question
v1
Can you change the value of a macro from the command line?
null
null
null
63c6481a5f004bf4898cf973
2023-02-14T19:16:38.931Z
Explain Code
v1
null
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "friends.h" #define INPUT_BUFFER_SIZE 256 #define INPUT_ARG_MAX_NUM 12 #define DELIM " \n" /* * Print a formatted error message to stderr. */ void error(char *msg) { fprintf(stderr, "Error: %s\n", msg); } /* * Read and process commands * Return: -1 for quit command * 0 otherwise */ int process_args(int cmd_argc, char **cmd_argv, User **user_list_ptr) { User *user_list = *user_list_ptr; if (cmd_argc <= 0) { return 0; } else if (strcmp(cmd_argv[0], "quit") == 0 && cmd_argc == 1) { return -1; } else if (strcmp(cmd_argv[0], "add_user") == 0 && cmd_argc == 2) { switch (create_user(cmd_argv[1], user_list_ptr)) { case 1: error("user by this name already exists"); break; case 2: error("username is too long"); break; } } else if (strcmp(cmd_argv[0], "list_users") == 0 && cmd_argc == 1) { list_users(user_list); } else if (strcmp(cmd_argv[0], "update_pic") == 0 && cmd_argc == 3) { User *user = find_user(cmd_argv[1], user_list); if (user == NULL) { error("user not found"); } else { switch (update_pic(user, cmd_argv[2])) { case 1: error("file not found"); break; case 2: error("filename too long"); break; } } } else if (strcmp(cmd_argv[0], "delete_user") == 0 && cmd_argc == 2) { if (delete_user(cmd_argv[1], user_list_ptr) == 1) { error("user by this name does not exist"); } } else if (strcmp(cmd_argv[0], "make_friends") == 0 && cmd_argc == 3) { switch (make_friends(cmd_argv[1], cmd_argv[2], user_list)) { case 1: error("users are already friends"); break; case 2: error("at least one user you entered has the max number of friends"); break; case 3: error("you must enter two different users"); break; case 4: error("at least one user you entered does not exist"); break; } } else if (strcmp(cmd_argv[0], "post") == 0 && cmd_argc >= 4) { // first determine how long a string we need int space_needed = 0; for (int i = 3; i < cmd_argc; i++) { space_needed += strlen(cmd_argv[i]) + 1; } // allocate the space char *contents = malloc(space_needed); // copy in the bits to make a single string strcpy(contents, cmd_argv[3]); for (int i = 4; i < cmd_argc; i++) { strcat(contents, " "); strcat(contents, cmd_argv[i]); } User *author = find_user(cmd_argv[1], user_list); User *target = find_user(cmd_argv[2], user_list); switch (make_post(author, target, contents)) { case 1: error("the users are not friends"); break; case 2: error("at least one user you entered does not exist"); break; } } else if (strcmp(cmd_argv[0], "profile") == 0 && cmd_argc == 2) { User *user = find_user(cmd_argv[1], user_list); if (print_user(user) == 1) { error("user not found"); } } else { error("Incorrect syntax"); } return 0; } /* * Tokenize the string stored in cmd. * Return the number of tokens, and store the tokens in cmd_argv. */ int tokenize(char *cmd, char **cmd_argv) { int cmd_argc = 0; char *next_token = strtok(cmd, DELIM); while (next_token != NULL) { if (cmd_argc >= INPUT_ARG_MAX_NUM - 1) { error("too many arguments!"); cmd_argc = 0; break; } cmd_argv[cmd_argc] = next_token; cmd_argc++; next_token = strtok(NULL, DELIM); } return cmd_argc; } int main(int argc, char* argv[]) { int batch_mode = (argc == 2); char input[INPUT_BUFFER_SIZE]; FILE *input_stream; // Create the heads of the empty data structure User *user_list = NULL; if (batch_mode) { input_stream = fopen(argv[1], "r"); if (input_stream == NULL) { perror("Error opening file"); exit(1); } } else { // interactive mode input_stream = stdin; } printf("Welcome to FriendMe! (Local version)\nPlease type a command:\n> "); while (fgets(input, INPUT_BUFFER_SIZE, input_stream) != NULL) { // only echo the line in batch mode since in interactive mode the user // just typed the line if (batch_mode) { printf("%s", input); } char *cmd_argv[INPUT_ARG_MAX_NUM]; int cmd_argc = tokenize(input, cmd_argv); if (cmd_argc > 0 && process_args(cmd_argc, cmd_argv, &user_list) == -1) { break; // can only reach if quit command was entered } printf("> "); } if (batch_mode) { fclose(input_stream); } // Delete all users. This should free all heap memory that was allocated // during the run of the program. Uncomment after you've implemented // deleting users. /*printf("Freeing all heap space.\n"); while (user_list != NULL) { delete_user(user_list->name, &user_list); }*/ return 0; }
null
null
63c6481a5f004bf4898cf973
2023-02-15T02:25:42.973Z
General Question
v1
How do I ask for equivalence to null
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T02:30:35.114Z
General Question
v1
Does strlen include the null pointer
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T02:33:46.917Z
General Question
v1
If a function is given a **struct, is the actual struct: *struct
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T16:23:09.164Z
General Question
v1
If I'm creating a struct, if I don't initialize the values, are they automatically set to null
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T16:50:07.294Z
General Question
v1
If my struct has a variable that is a list of structs, can I set that value to NULL
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T16:54:21.652Z
General Question
v1
What is the else if statement in C called
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T16:56:42.602Z
General Question
v1
How do I compare strings
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T16:59:26.723Z
General Question
v1
Let User be a struct. If I wanted a function to return a pointer to a User, would the return statement be *user_name or **user_name
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T17:09:35.623Z
General Question
v1
Let char *name1 be a string. If I want a new char *name2 to be equal to name1, do I do char *name2 = *name1 or char *name2 = name1
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T17:14:45.856Z
General Question
v1
What does open return if a file doesn't exist
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T18:00:18.268Z
General Question
v1
If an object has a list of structs, how do I find the size of this list.
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T18:03:20.962Z
General Question
v1
is an int the same as an unsigned integer
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T18:11:18.211Z
General Question
v1
Can I use index numbers to iterate through a list of structs
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T18:18:50.782Z
General Question
v1
If User is a struct that has the variable: struct user *friends[MAX_FRIENDS], If new_user is an empty User, would I be able to do new_user->friends[32]; to initialize the array
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T18:27:02.021Z
General Question
v1
If a macro is defined in a different file, but the same folder, can that macro value be accessed from a different file.
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T18:30:10.553Z
General Question
v1
If *name is a string, do I do strlen(*name) or strlen(name)
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T18:45:49.306Z
General Question
v1
If I have a struct User, and User has a variable: struct user *friends[MAX_FRIENDS], would I have to malloc the individual index position when I'm placing a User in them
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T18:59:07.172Z
General Question
v1
Is a pointer to a NULL == NULL
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T19:32:46.458Z
General Question
v1
How do I print the contents f a file using fopen
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T21:13:29.570Z
General Question
v1
If my struct has another struct as a variable, do I have to use malloc for that variable
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T21:15:26.467Z
General Question
v1
If I have struct user, and a variable for User is: struct post *first_post;, if I'm initializing a new User called new_user, would I have to use malloc on new_user->first_post;
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T21:26:22.649Z
General Question
v1
Should the tail of a linked list use malloc on it's next variable
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T21:51:36.173Z
General Question
v1
How do I use time_t to record the time
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T22:01:07.599Z
General Question
v1
If I'm creating a function to free heap memory. Should I give the function the pointer to the variable or just the variable
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T22:07:00.966Z
General Question
v1
What is the function that frees hap memory
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T22:09:03.773Z
Question from Code
v1
Am I freeing the right memory
int remove_post(Post **head_post){ Post *head = *head_post; free(head); }
null
null
63c6481a5f004bf4898cf973
2023-02-15T22:10:00.484Z
Question from Code
v1
Am I freeing the right memory
int remove_post(struct post **head_post){ free(**head_post); }
null
null
63c6481a5f004bf4898cf973
2023-02-15T22:11:00.135Z
Question from Code
v1
Am I freeing the right memory
int remove_post(struct post **head_post){ struct post *head = *head_post; free(head); }
null
null
63c6481a5f004bf4898cf973
2023-02-15T22:11:59.093Z
Question from Code
v1
What memory am I freeing
int remove_post(struct post **head_post){ free(*head); }
null
null
63c6481a5f004bf4898cf973
2023-02-15T22:12:23.004Z
Question from Code
v1
What memory am I freeing
int remove_post(struct post **head_post){ free(*head_post); }
null
null
63c6481a5f004bf4898cf973
2023-02-15T22:12:45.127Z
Question from Code
v1
Am I freeing the right memory
int remove_post(struct post **head_post){ free(*head_post); }
null
null
63c6481a5f004bf4898cf973
2023-02-15T22:14:01.627Z
Question from Code
v1
If I'm treeing to free the object, am I freeing the right memory
int remove_post(struct post **post){ free(*post); }
null
null
63c6481a5f004bf4898cf973
2023-02-15T22:22:05.173Z
General Question
v1
Is this valid: &(head->next)
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T22:52:20.478Z
General Question
v1
If I have a struct user with the variable time_t *date, do I free free(&(head->date)) or free(head->date);
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T23:07:15.660Z
General Question
v1
How do I set a char array after it's been initialized
null
null
null
63c6481a5f004bf4898cf973
2023-02-15T23:17:59.973Z
Help Fix Code
v1
null
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; int create_user(const char *name, User **user_ptr_add) { User *new_user = malloc(sizeof(User)); new_user->name = malloc(sizeof(char) * MAX_NAME); strcpy(new_user->name, name); new_user->profile_pic = malloc(sizeof(char) * MAX_NAME); new_user->profile_pic[0] = '\0'; new_user->first_post = malloc(sizeof(Post)); new_user->first_post = NULL; new_user->friends = malloc(sizeof(User) * MAX_FRIENDS); }
Create a struct user
null
63c6481a5f004bf4898cf973
2023-02-15T23:32:21.087Z
Help Fix Code
v1
null
User *find_user(const char *name, const User *head) { if(head == NULL){ return NULL; } User *curr = *head; if(strcmp(curr->name, name) == 0){ return *curr; } while(curr->next != NULL) curr = curr->next; if(strcmp(curr->name, name) == 0){ return *curr; } return NULL; }
Traverse through a linked structure to find a specific User
null
63c6481a5f004bf4898cf973
2023-02-15T23:54:32.249Z
Help Fix Code
v1
null
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; int create_user(const char *name, User **user_ptr_add) { if(find_user(name, *user_ptr_add) != NULL){ return 1; } if(MAX_NAME < strlen(name) + 1){ return 2; } else{ User *new_user = malloc(sizeof(User)); strcpy(new_user->name, name); new_user->profile_pic[0] = '\0'; new_user->first_post = malloc(sizeof(Post)); new_user->first_post = NULL; if(*user_ptr_add == NULL){ new_user->next = *user_ptr_add; **user_ptr_add = *new_user; } else{ User *curr = *user_ptr_add; while(curr->next != NULL){ curr = curr->next; } new_user->next = curr->next; curr->next = new_user; } return 0; } return -1; }
Add a new user to the end of the linked structure
null
63c6481a5f004bf4898cf973
2023-02-16T00:02:09.917Z
Help Fix Code
v1
null
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; typedef struct post { char author[MAX_NAME]; char *contents; time_t *date; struct post *next; } Post; int make_post(const User *author, User *target, char *contents){ if(author == NULL || target == NULL){ return 2; } int not_detected = 1; for(int i = 0; i < MAX_FRIENDS; i++){ if(strcmp(author->friends[i]->name, target->name) == 0){ not_detected = 0; break; } } if(not_detected == 1){ return not_detected; } else{ Post *new_post = malloc(sizeof(Post)); strcpy(new_post->author, author->name); strcpy(new_post->contents, contents); new_post->date = malloc(sizeof(time_t)); *new_post->date = time(NULL); new_post->next = target->first_post; target->first_post = new_post; return 0; } return -1; }
Create a post and set it to target's first_post
null
63c6481a5f004bf4898cf973
2023-02-16T00:05:52.291Z
General Question
v1
How do I make scanf ignore spaces
null
null
null
63c6481a5f004bf4898cf973
2023-02-16T00:12:24.012Z
General Question
v1
How do I make scanf ignore spaces but not \n
null
null
null
63c6481a5f004bf4898cf973
2023-02-16T00:20:01.653Z
Help Fix Code
v1
null
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; typedef struct post { char author[MAX_NAME]; char *contents; time_t *date; struct post *next; } Post; int delete_user(const char *name, User **user_ptr_del) { printf("1"); int no_exist = 1; User *head = *user_ptr_del; User *b_head = *user_ptr_del; while(head != NULL){ printf("1"); if(strcmp(head->name, name) == 0){ no_exist = 0; break; } b_head = head; head = head->next; printf("1"); } if(no_exist == 1){ return 1; } else{ remove_post(&(head->first_post)); for(int i = 0; i < MAX_FRIENDS; i++){ if(head->friends[i] != NULL){ remove_friend(head->name, &(head->friends[i])); } } if(strcmp(b_head->name, head->name) == 0){ *user_ptr_del = (head->next); free(head); return 0; } else{ b_head->next = head->next; free(head); return 0; } } return -1; }
Delete a User from the linked structure
null
63c6481a5f004bf4898cf973
2023-02-16T00:20:55.543Z
Help Fix Code
v1
null
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; typedef struct post { char author[MAX_NAME]; char *contents; time_t *date; struct post *next; } Post; int delete_user(const char *name, User **user_ptr_del) { int no_exist = 1; User *head = *user_ptr_del; User *b_head = *user_ptr_del; while(head != NULL){ if(strcmp(head->name, name) == 0){ no_exist = 0; break; } b_head = head; head = head->next; } if(no_exist == 1){ return 1; } else{ remove_post(&(head->first_post)); for(int i = 0; i < MAX_FRIENDS; i++){ if(head->friends[i] != NULL){ remove_friend(head->name, &(head->friends[i])); } } if(strcmp(b_head->name, head->name) == 0){ *user_ptr_del = (head->next); free(head); return 0; } else{ b_head->next = head->next; free(head); return 0; } } return -1; }
Delete a User from the linked structure
null
63c6481a5f004bf4898cf973
2023-02-16T01:43:43.990Z
Help Fix Code
v1
null
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; typedef struct post { char author[MAX_NAME]; char *contents; time_t *date; struct post *next; } Post; int remove_post(Post **head_post){ Post *head = *head_post; if(head->next == NULL){ printf("1"); free(head->next); } else{ remove_post(&(head->next)); } free(head->date); free(*head_post); return 0; }
Delete Posts in a linked structure recursively
null
63c6481a5f004bf4898cf973
2023-02-16T01:44:22.286Z
Help Fix Code
v1
null
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; typedef struct post { char author[MAX_NAME]; char *contents; time_t *date; struct post *next; } Post; int remove_post(Post **head_post){ Post *head = *head_post; if(head->next == NULL){ free(head->next); } else{ remove_post(&(head->next)); } free(head->date); free(*head_post); return 0; }
Delete Posts in a linked structure recursively
null
63c6481a5f004bf4898cf973
2023-02-16T01:46:42.208Z
Question from Code
v1
Why does this code cause a segmentation fault
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; typedef struct post { char author[MAX_NAME]; char *contents; time_t *date; struct post *next; } Post; int remove_post(Post **head_post){ Post *head = *head_post; if(head->next == NULL){ free(head->next); } else{ remove_post(&(head->next)); } free(head->date); free(*head_post); return 0; }
null
null
63c6481a5f004bf4898cf973
2023-02-16T01:57:59.498Z
Question from Code
v1
Why is this code creating a segmentation fault
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; typedef struct post { char author[MAX_NAME]; char *contents; time_t *date; struct post *next; } Post; int make_post(const User *author, User *target, char *contents){ if(author == NULL || target == NULL){ return 2; } int not_detected = 1; for(int i = 0; i < MAX_FRIENDS; i++){ if(strcmp(author->friends[i]->name, target->name) == 0){ not_detected = 0; break; } } if(not_detected == 1){ return not_detected; } else{ Post *new_post = malloc(sizeof(Post)); strcpy(new_post->author, author->name); strcpy(new_post->contents, contents); new_post->date = malloc(sizeof(time_t)); *new_post->date = time(NULL); new_post->next = target->first_post; target->first_post = new_post; return 0; } return -1; }
null
null
63c6481a5f004bf4898cf973
2023-02-17T19:51:01.826Z
General Question
v1
What is the minimum value strcpy work with
null
null
null
63c6481a5f004bf4898cf973
2023-02-22T21:53:19.784Z
General Question
v1
Does strcpy work on a char * that's been malloced
null
null
null
63c6481a5f004bf4898cf973
2023-02-24T20:25:06.859Z
General Question
v1
After declaring a char *, how do I fill it.
null
null
null
63c6481a5f004bf4898cf973
2023-02-24T20:30:46.587Z
General Question
v1
Can you add a variable to the heap after having initialized it
null
null
null
63c6481a5f004bf4898cf973
2023-02-24T20:36:40.912Z
General Question
v1
If I declare a char[15], does that mean 16 bytes are allocated to the char * as it has 15 bytes of characters as well as one byte for the null terminator?
null
null
null
63c6481a5f004bf4898cf973
2023-02-26T20:48:30.317Z
General Question
v1
Can you put '\n' as a character in a string
null
null
null
63c6481a5f004bf4898cf973
2023-02-27T20:47:12.638Z
General Question
v1
would the output of strlen("five") be four
null
null
null
63c6481a5f004bf4898cf973
2023-02-27T21:27:51.236Z
General Question
v1
Can you malloc something when it's value has already been assigned
null
null
null
63c6481a5f004bf4898cf973
2023-02-27T21:36:07.309Z
General Question
v1
If you have a struct with a char *, and you've used malloc on that char, when freeing the memory, do you free(&thing->name) or free(thing->name) where thing is the variable name of the struct and name is the char * in the struct.
null
null
null
63c6481a5f004bf4898cf973
2023-02-28T18:25:46.139Z
General Question
v1
If I declare a char array like this: char name[x]; Would x be equivalent to the number of bits the array can hold
null
null
null
63c6481a5f004bf4898cf973
2023-02-28T19:12:38.543Z
General Question
v1
If I have int array[3] = {1, 2, 3}; would the value of array be the pointer to the first int?
null
null
null
63c6481a5f004bf4898cf973
2023-03-11T22:06:19.671Z
General Question
v2
How do child processes return information to the parent process
null
null
null
63c6481a5f004bf4898cf973
2023-03-13T17:37:54.368Z
General Question
v2
Can you create a 2d array by using to square brackets
null
null
null
63c6481a5f004bf4898cf973
2023-03-13T17:39:14.402Z
General Question
v2
Is argc one more than the amount of inputs
null
null
null
63c6481a5f004bf4898cf973
2023-03-13T17:56:41.909Z
General Question
v2
If I'm using pipes pipes, and I want to read an int, do I give the address of the int
null
null
null
63c6481a5f004bf4898cf973
2023-03-13T18:09:46.260Z
General Question
v2
If I use pipes to read an integer, how do I use that integer from fd
null
null
null
63c6481a5f004bf4898cf973
2023-03-13T23:39:10.852Z
General Question
v2
If I'm reading a file, how do I make sure I read it line by line
null
null
null
63c6481a5f004bf4898cf973
2023-03-13T23:40:58.779Z
General Question
v2
Do a lines of a file end with '\n' or '\0'
null
null
null
63c6481a5f004bf4898cf973
2023-03-13T23:52:19.126Z
General Question
v2
If I have a FILE *fp, do I use fopen(fp, "r") to open the file for reading
null
null
null
63c6481a5f004bf4898cf973
2023-03-14T00:19:54.489Z
General Question
v2
If I use fgets, and \n is the last index position of the string, does fgets replace \n with \0
null
null
null
63c6481a5f004bf4898cf973
2023-03-17T19:51:43.718Z
General Question
v2
Can you add index positions to an array
null
null
null
63c6481a5f004bf4898cf973
2023-03-17T20:25:05.432Z
General Question
v2
How do I use FSEEK to reset my file position to the top of the file
null
null
null
63c6481a5f004bf4898cf973
2023-03-17T20:36:04.304Z
General Question
v2
If I have a struct rule, does this allow me to fill the array properly: struct rule rules_to_use[10]; struct rule *new_rule = malloc(sizeof(struct rule)); rules_to_use[0] = new_rule;
null
null
null
63c6481a5f004bf4898cf973
2023-03-17T20:42:09.068Z
General Question
v2
How do I make sure I'm assigning a read-only string to a member of a struct so that I don't use more memory than is assigned to the struct
null
null
null
63c6481a5f004bf4898cf973
2023-03-17T20:49:07.883Z
General Question
v2
If I use strcpy, will the destination string will have different memory address than the source string?
null
null
null
63c6481a5f004bf4898cf973
2023-03-17T20:52:34.226Z
General Question
v2
If I do char *name = "bob"; will *name have the memory address of the read only memory of bob, meaning it's size will only be the size of a pointer?
null
null
null
63c6481a5f004bf4898cf973
2023-03-17T20:55:23.496Z
General Question
v2
char *rule_names[max_rules]; Is this an array of pointers to strings?
null
null
null
63c6481a5f004bf4898cf973
2023-03-18T00:18:58.309Z
General Question
v2
How do I use FSEEK to go up one line a file without knowing the size of the line
null
null
null
63c6481a5f004bf4898cf973
2023-03-18T04:30:30.614Z
General Question
v2
Can I declare a pointer first and then use malloc in a separate line on the pointer
null
null
null
63c6481a5f004bf4898cf973
2023-04-04T19:12:04.162Z
General Question
v2
If I have code that is accepting input from a socket, and will stop when it detects "\r\n" using the function strstr, how do I print "\r\n" from input
null
null
null
63c6481a5f004bf4898cf973
2023-04-25T17:28:46.922Z
General Question
v2
char *flights[3]; Is this equivalent to a char **flights = malloc(3* sizeof(char *));
null
null
null
63c6481a5f004bf4898cf973
2023-04-25T19:18:58.442Z
General Question
v2
When trying to send a sigaction signal to a process from shell (assume it is SIGUSR1), is it: kill -USR1 pid or kill -SIGUSR1 pid
null
null
null
63c6481a5f004bf4898cf973
2023-04-25T19:34:35.752Z
General Question
v2
is it chmod 555 file.txt or chmod file.txt 555
null
null
null
63c6481a5f004bf4898cf973
2023-04-25T19:40:39.138Z
General Question
v2
What is : cp ../*.in . do
null
null
null
63c6481a5f004bf4898cf973
2023-04-25T20:26:40.072Z
General Question
v2
if I do printf("%d", x); will it print the bit value of x
null
null
null
63c6481a5f004bf4898cf973
2023-04-25T20:53:14.758Z
General Question
v2
if you have char *name1 and char *name2; To set the address of name1 to name2, do you do name1 = name2;
null
null
null
63c6481a5f004bf4898cf973
2023-04-25T20:55:50.210Z
General Question
v2
if you have char *name1 and char *name2. To set the address of name1 to the address of name2, do you do name1 = name2;
null
null
null
63c6481a5f004bf4898cf973
2023-04-25T21:48:53.281Z
General Question
v2
What does r+ do with fopen
null
null
null
63c6481a5f004bf4898cf978
2023-01-18T00:13:44.889Z
General Question
v1
I have this error with C program: phone.c:6:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[10]’ [-Wformat=] 6 | scanf("%s %d", &str, &num); | ~^ ~~~~ | | | | char * char (*)[10] how do i fix it?
null
null
null