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
63c648f15f004bf4898d012a
2023-03-14T04:05:17.713Z
Question from Code
v2
What does the program print to stderr if the user presses Ctrl+C at the moment when the program is at position C?
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; }
null
null
63c648f15f004bf4898d012a
2023-03-14T04:06:36.406Z
Question from Code
v2
What does the program print to stderr if the user presses Ctrl+C at the moment when the program is at position C? The answer is not "start inside 8 outside 8"
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; }
null
null
63c648f15f004bf4898d012a
2023-03-14T04:10:30.833Z
Question from Code
v2
What does the program print to stderr if the user presses Ctrl+C at the moment when the program is at position C?
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; }
null
null
63c648f15f004bf4898d012a
2023-03-16T00:14:06.829Z
Question from Code
v2
how to fix
Type '{ open: boolean; setOpen: Dispatch<SetStateAction<boolean>>; freqProps: any; perfProps: any; speedup: number; setSpeedup: Dispatch<SetStateAction<number>>; }' is not assignable to type 'IntrinsicAttributes & { open: any; setOpen: any; }' .Property 'freqProps' does not exist on type 'IntrinsicAttributes & { open: any; setOpen: any; }'.139 | open = {open} 140 | setOpen = {setOpen} > 141 | freqProps = {frequencyProps} | ^^^^^^^^^142 | perfProps = { performanceProps} 143 | speedup = {speedup} 144 | setSpeedup = {setSpeedup}
null
null
63c648f15f004bf4898d012a
2023-04-04T02:49:22.080Z
General Question
v2
Consider the follow code: subject=CSC Using subject, write a command to output: Last week of CSC209
null
null
null
63c648f15f004bf4898d012a
2023-04-04T02:50:17.773Z
General Question
v2
Consider the follow code: subject=CSC Using subject, write a command in the shell to output: Last week of CSC209
null
null
null
63c648f15f004bf4898d012a
2023-04-22T23:54:12.984Z
Help Fix Code
v2
modify the program so that each process creates exactly one a new process. Keep the printf call for all processes.
#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"); exit(1); } printf("ppid = %d, pid = %d, i = %d\n", getppid(), getpid(), i); } return 0; }
null
null
63c648f15f004bf4898d012a
2023-04-23T00:31:07.748Z
Help Fix Code
v2
reads a user id and password from stdin, creates a new process to run the validate program, sends it the user id and password, and prints a message to stdout reporting whether the validation is successful. Your program should use the exit status of the validate program to determine which of the three following messages to print.
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #define MAXLINE 256 #define SUCCESS "Password verified\n" #define INVALID "Invalid password\n" #define NO_USER "No such user\n" int main(void) { char user_id[MAXLINE]; char password[MAXLINE]; /* The user will type in a user name on one line followed by a password on the next. DO NOT add any prompts. The only output of this program will be one of the messages defined above. Please read the comments in validate carefully */ if(fgets(user_id, MAXLINE, stdin) == NULL) { perror("fgets"); exit(1); } if(fgets(password, MAXLINE, stdin) == NULL) { perror("fgets"); exit(1); } user_id[strcspn(user_id, "\n")] = '\0'; password[strcspn(password, "\n")] = '\0'; // fork process pid_t n = fork(); if (n < 0){ perror("fork"); exit(1); } if (n == 0) { // child process replace with validate program int a = execl("./validate", "validate", NULL); if (a == -1){ perror("execl"); exit(1); } write(STDIN_FILENO, user_id, strlen(user_id) + 1); write(STDIN_FILENO, password, strlen(password)+1); exit(a); } else if (n>0) { // parent process int status; pid_t child_pid = wait(&status); if (child_pid == -1){ perror("wait"); exit(1); } if (WIFEXITED(status)){ int exit_status = WEXITSTATUS(status); if (exit_status == 0){ printf(SUCCESS); } else if (exit_status == 2){ printf(INVALID); } else if (exit_status == 3){ printf(NO_USER); } } } return 0; }
null
null
63c648f15f004bf4898d012a
2023-04-23T19:26:27.073Z
General Question
v2
How to make a program that takes an int n, and creates that n amount of processes, where the parent always creates only 1 new process up till n processes
null
null
null
63c648f15f004bf4898d012a
2023-04-23T20:16:39.733Z
Question from Code
v2
Why does my code return: error could not read from stdin
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #define MAXLINE 256 #define SUCCESS "Password verified\n" #define INVALID "Invalid password\n" #define NO_USER "No such user\n" int main(void) { char user_id[MAXLINE]; char password[MAXLINE]; if (fgets(user_id, MAXLINE, stdin) == NULL) { perror("fgets"); exit(1); } if (fgets(password, MAXLINE, stdin) == NULL) { perror("fgets"); exit(1); } user_id[31] = '\0'; password[9] = '\0'; int pipefd[2]; int a = pipe(pipefd); if (a < 0) { perror("pipe"); exit(1); } int n = fork(); if (n < 0) { perror("fork"); exit(1); } else if (n == 0) { close(pipefd[1]); dup2(pipefd[0], STDIN_FILENO); int n = execl("./validate", "validate", NULL); if (n < 0) { perror("execl"); exit(1); } } else { close(pipefd[0]); write(pipefd[1], user_id, sizeof(user_id)); write(pipefd[1], password, sizeof(password)); close(pipefd[1]); int status; wait(&status); if (WIFEXITED(status)) { int n = WEXITSTATUS(status); if (n == 0) { printf(SUCCESS); } else if (n == 2) { printf(INVALID); } else if (n == 3) { printf(NO_USER); } else { printf("Error"); return -1; } } } return 0; }
null
null
63c648f35f004bf4898d0139
2023-01-27T02:44:47.300Z
General Question
v1
i have a variable of type *char[10] that I want to pass into a function, how should i write the function call and the parameters?
null
null
null
63c648f35f004bf4898d0139
2023-01-27T04:05:16.198Z
General Question
v1
what is the difference between (*var)[0] and *var[0]
null
null
null
63c648f35f004bf4898d0139
2023-02-03T19:11:43.430Z
General Question
v1
why am I getting this error ../sysdeps/x86_64/multiarch/strcmp-avx2.S: No such file or directory. when I run strcmp
null
null
null
63c648f35f004bf4898d0139
2023-02-03T19:20:10.699Z
Question from Code
v1
why do i get the warning that this is a comparison between pointer and integer?
s[i] == "?"
null
null
63c648f35f004bf4898d0139
2023-02-10T23:02:51.298Z
Question from Code
v1
when printing some values from this array, why does it print (0, 0, 0) between each line?
struct pixel **read_pixel_array(FILE *image, int pixel_array_offset, int width, int height) { struct pixel **pixel_data = malloc(height * sizeof(struct pixel *)); fseek(image, pixel_array_offset, SEEK_SET); for (int i = 0; i < height; i++) { pixel_data[i] = malloc(width * sizeof(struct pixel)); for (int j = 0; j < width / 3; j++) { fread(&(pixel_data[i][j].blue), 1, 1, image); fread(&(pixel_data[i][j].green), 1, 1, image); fread(&(pixel_data[i][j].red), 1, 1, image); } } return pixel_data; }
null
null
63c648f35f004bf4898d0139
2023-02-11T20:22:58.490Z
Question from Code
v1
given this user struct, when I create a new user will I have to allocate memory on the heap separately for the friends array?
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;
null
null
63c648f35f004bf4898d0139
2023-02-11T20:24:01.850Z
Question from Code
v1
given the friends array attribute in the code, how would I add to the array know its current size?
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;
null
null
63c648f35f004bf4898d0139
2023-02-11T20:25:01.440Z
Question from Code
v1
how would i add users to the friends array?
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;
null
null
63c648f35f004bf4898d0139
2023-02-11T20:25:35.831Z
Question from Code
v1
when iterating through the friends array, how do i know when i reach an empty slot?
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;
null
null
63c648f35f004bf4898d0139
2023-02-11T20:53:33.535Z
Question from Code
v1
when i create a new user given this struct, how would i set the friends array to be full of NULL values?
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;
null
null
63c648f35f004bf4898d0139
2023-03-03T06:59:40.997Z
Question from Code
v1
how would i modify this code so that new children do not create additional processes? meaning only the original parent calls fork.
#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"); exit(1); } printf("ppid = %d, pid = %d, i = %d\n", getppid(), getpid(), i); } return 0; }
null
null
63c648f35f004bf4898d0139
2023-03-03T07:03:45.811Z
Question from Code
v1
modify the program so that each process creates exactly one a new process
#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"); exit(1); } printf("ppid = %d, pid = %d, i = %d\n", getppid(), getpid(), i); } return 0; }
null
null
63c648f35f004bf4898d0139
2023-03-03T07:04:11.822Z
Help Fix Code
v1
null
#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"); exit(1); } printf("ppid = %d, pid = %d, i = %d\n", getppid(), getpid(), i); } return 0; }
modify the program so that each process creates exactly one a new process
null
63c648f35f004bf4898d0139
2023-03-03T07:09:30.843Z
Help Fix Code
v1
null
#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"); exit(1); } printf("ppid = %d, pid = %d, i = %d\n", getppid(), getpid(), i); } return 0; }
modify the program so that the new children do not create additional processes. Only the original parent calls fork
null
63c648f35f004bf4898d0139
2023-03-03T07:11:05.199Z
Help Fix Code
v1
null
#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"); exit(1); } printf("ppid = %d, pid = %d, i = %d\n", getppid(), getpid(), i); } return 0; }
modify the program so that the new children do not create additional processes
null
63c648f35f004bf4898d0139
2023-03-03T07:38:58.932Z
Help Fix Code
v1
null
#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"); exit(1); } printf("ppid = %d, pid = %d, i = %d\n", getppid(), getpid(), i); } return 0; }
each process creates exactly one a new process
null
63c648f35f004bf4898d0139
2023-03-31T02:22:01.633Z
General Question
v2
how do i clean any newlines from input
null
null
null
63c648f35f004bf4898d0139
2023-04-02T01:54:26.748Z
Question from Code
v2
directive output truncated writing 48 bytes into a region of size between 0 and 2 [-Werror=format-truncation=] why am i getting this warning when compiling
int ret = snprintf(temp2, sizeof(buf), "Name :%s\r\n\r\n------------------------------------------\r\n", user->name);
null
null
63c648f35f004bf4898d0139
2023-04-22T23:56:06.139Z
Question from Code
v2
what will be stored in memory after running this line?
char n = 25;
null
null
63c648f35f004bf4898d0139
2023-04-23T00:01:19.576Z
Question from Code
v2
what would be printed after running this code?
void fun(int *i, char *j) { *i = *i * 2; *j = *j * 2; } int main() { int m = 25; char n = 25; fun(&m, &n); printf("%d, %c\n", m, n); return 0; }
null
null
63c648f35f004bf4898d0139
2023-04-23T00:04:40.272Z
Question from Code
v2
what would be printed from this code?
int main() { double r[] = {5, 6.78, 0.12, 0}; printf("%ld\n", sizeof(r) / sizeof(r[0])); return 0; }
null
null
63c648f35f004bf4898d0139
2023-04-23T00:06:45.845Z
Question from Code
v2
what would be printed from this code?
int main() { int number = 16; printf("%d %d\n", number << 2, number >> 2); return 0; }
null
null
63c648f35f004bf4898d0139
2023-04-23T00:09:40.258Z
General Question
v2
how can I use a C program to calculate the optimal number of cheese strings I should eat in one day?
null
null
null
63c648f35f004bf4898d013e
2023-01-24T01:35:45.490Z
Explain Code
v1
null
#include <stdio.h> int main(void){ long n, sum = 0; printf("This program sums a series of integers.\n"); printf("Enter integers (0 to terminate): "); scanf("%ld", &n); while (n!=0){ sum +=n; scanf("%ld", &n); } printf("The sum is: %ld\n",sum); return 0;}
null
null
63c648f45f004bf4898d0148
2023-01-26T05:44:08.360Z
Help Fix Code
v1
null
int **fib(int **fib_squence, int count) { fib_squence = malloc(sizeof(int) * count); int n1 = 0; int n2 = 1; int sum = 0; for (int i = 0; i < count; i++) { fib_squence[i] = sum; sum = n1 + n2; n1 = n2; n2 = sum; } return fib_squence; }
output fibonacci sequence
null
63c648f45f004bf4898d0148
2023-01-30T04:50:46.026Z
General Question
v1
how to pipe input in c?
null
null
null
63c648f65f004bf4898d0152
2023-01-18T00:25:54.010Z
General Question
v1
explain pointers
null
null
null
63c648f65f004bf4898d0152
2023-01-18T00:36:17.941Z
General Question
v1
Create a function that takes as parameters three numbers which represent a date (day, month, year), and verifies if this date is valid by returning 1 for valid, and 0 for invalid. You will have to check that the year is a positive number, the month is within the correct range, and the day is in the correct range within the month.
null
null
null
63c648f65f004bf4898d0152
2023-01-23T17:56:55.823Z
Explain Code
v1
null
int main() { // this allocates space for the 2 pointers int **pointers = malloc(sizeof(int *) * 2); // the first pointer points to a single integer pointers[0] = malloc(sizeof(int)); // the second pointer pointes to an array of 3 integers pointers[1] = malloc(sizeof(int) * 3); // let's set their values *pointers[0] = 55; pointers[1][0] = 100; pointers[1][1] = 200; pointers[1][2] = 300; // do other stuff with this memory // now time to free the memory as we are finished with the data-structure // first we need to free the inner pieces free(pointers[0]); free(pointers[1]); // now we can free the space to hold the array of pointers themselves free(pointers); return 0; }
null
null
63c648f65f004bf4898d0152
2023-01-23T17:58:09.020Z
General Question
v1
assign a dynamically allocated char * array of length 4
null
null
null
63c648f65f004bf4898d0152
2023-02-27T08:43:11.482Z
Explain Code
v1
null
int *squares_to_10 = squares(10);
null
null
63c648f65f004bf4898d0157
2023-01-17T19:45:37.219Z
Explain Code
v1
null
#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char phone[11]; int i, len; scanf("%s %d%n", phone, &i, &len); // len = strlen(i); while (i != EOF && len == 1) { if (i < -1 || i > 9) { printf("ERROR\n"); return 1; } else if (i == -1) { printf("%s\n", phone); } else { printf("%c\n", phone[i]); } scanf(" %d%n", &i, &len); } return 0; }
null
null
63c648f65f004bf4898d0157
2023-01-17T19:46:55.075Z
Help Fix Code
v1
null
#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char phone[11]; int i, len; scanf("%s %d%n", phone, &i, &len); // len = strlen(i); while (i != EOF && len == 1) { if (i < -1 || i > 9) { printf("ERROR\n"); return 1; } else if (i == -1) { printf("%s\n", phone); } else { printf("%c\n", phone[i]); } scanf(" %d%n", &i, &len); } return 0; }
stop while loop when end-of-file reached with scanf
null
63c648f65f004bf4898d0157
2023-01-17T20:35:07.313Z
Explain Code
v1
null
char *result[2];
null
null
63c648f65f004bf4898d0157
2023-01-17T20:35:53.581Z
Explain Code
v1
null
char *result[2]; x = result[0];
null
null
63c648f65f004bf4898d0157
2023-01-17T20:52:59.770Z
Explain Code
v1
null
#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char phone[11]; int i; if (scanf("%10s %d", phone, &i) != 2) { return 0; } do { if (i < -1 || i > 9) { printf("ERROR\n"); return 1; } else if (i == -1) { printf("%s\n", phone); } else { printf("%c\n", phone[i]); } } while (scanf(" %d", &i) == 1); return 0; }
null
null
63c648f65f004bf4898d0157
2023-01-23T21:58:17.408Z
Question from Code
v1
why doesn't size take the value argc - 1
int *build_array(char **strs, int size) { int *arr = malloc(size * sizeof(int)); for (int i = 0; i < size; i++) { arr[i] = strtol(strs[i + 1], NULL, 10); } return arr; } int main(int argc, char **argv) { int *full_array = build_array(argv, argc - 1); return 0; }
null
null
63c648f65f004bf4898d0157
2023-01-23T21:59:08.589Z
Explain Code
v1
null
int *build_array(char **strs, int size) { int *arr = malloc(size * sizeof(int)); for (int i = 0; i < size; i++) { arr[i] = strtol(strs[i + 1], NULL, 10); } return arr; } int main(int argc, char **argv) { int *full_array = build_array(argv, argc - 1); return 0; }
null
null
63c648f65f004bf4898d0157
2023-01-25T17:44:17.017Z
Help Fix Code
v1
null
int s = scanf("%*c%9s %*d %*s %*s %d %*s %*d %*s %s", perms, &size, name);
parse input from ls -l
null
63c648f85f004bf4898d016b
2023-02-07T19:42:34.563Z
General Question
v1
what is a string literal
null
null
null
63c648f85f004bf4898d016b
2023-02-07T20:21:50.865Z
General Question
v1
how to use time and ctime functions to find the current time and convert a time value to a string
null
null
null
63c648f85f004bf4898d016b
2023-02-07T20:34:48.266Z
General Question
v1
what are the return values for fopen
null
null
null
63c648f85f004bf4898d016b
2023-02-09T19:33:28.227Z
General Question
v1
how to use time_t to save the current time
null
null
null
63c648f85f004bf4898d016b
2023-02-12T02:29:06.928Z
Question from Code
v1
how to output the printf
#include <stdio.h> int main() { #ifdef MACRO printf("%d\n", MACRO); #endif return 0; }
null
null
63c648f85f004bf4898d016b
2023-02-12T02:29:38.953Z
General Question
v1
when is MACRO defined in preprocessor
null
null
null
63c648f85f004bf4898d016b
2023-02-12T02:31:28.805Z
Question from Code
v1
How to compile this code and have it print 5
#include <stdio.h> int main() { #ifdef MACRO printf("%d\n", MACRO); #endif return 0; }
null
null
63c648f85f004bf4898d016b
2023-02-12T02:34:28.618Z
Question from Code
v1
What will this declaration line become after the program has passed through the C pre-processor?
#define MAXNAME = 32; char name[MAXNAME];
null
null
63c648f85f004bf4898d016b
2023-02-12T02:38:00.462Z
Question from Code
v1
what is the value of MAXNAME
#define MAXNAME = 32; char name[MAXNAME];
null
null
63c648f85f004bf4898d016b
2023-02-12T03:08:16.528Z
General Question
v1
what does ? mean in C
null
null
null
63c648f85f004bf4898d016b
2023-02-12T03:21:47.541Z
Question from Code
v1
What will be the output of the following program fragment?
#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))); }
null
null
63c648f85f004bf4898d016b
2023-02-12T03:26:37.642Z
Question from Code
v1
what does this do
#define SUPERVISOR(regular) regular + 5
null
null
63c648f85f004bf4898d016b
2023-02-12T15:38:00.404Z
General Question
v1
what does stat do
null
null
null
63c648f85f004bf4898d016b
2023-02-13T16:27:59.349Z
General Question
v1
how to write function prototypes for helper functions at top of file
null
null
null
63c648f85f004bf4898d016b
2023-02-23T19:52:55.621Z
General Question
v1
what type is string literal
null
null
null
63c648f85f004bf4898d016b
2023-02-23T19:53:20.585Z
General Question
v1
what is the difference between string literal and string variable
null
null
null
63c648f85f004bf4898d016b
2023-02-24T15:31:29.351Z
General Question
v1
what does wait do
null
null
null
63c648f85f004bf4898d016b
2023-02-24T21:16:11.920Z
General Question
v1
What does the command-line arguments -k 3 myfile mean .
null
null
null
63c648f85f004bf4898d016b
2023-02-25T02:04:57.680Z
General Question
v1
what is size_t
null
null
null
63c648f85f004bf4898d016b
2023-02-25T02:20:56.785Z
General Question
v1
what does fread do
null
null
null
63c648f85f004bf4898d016b
2023-02-25T15:30:05.684Z
General Question
v1
what is a zombie process
null
null
null
63c648f85f004bf4898d016b
2023-02-25T15:51:13.285Z
General Question
v1
what is a environment
null
null
null
63c648f85f004bf4898d016b
2023-02-26T17:58:17.876Z
General Question
v1
what does % mean in makefile
null
null
null
63c648f85f004bf4898d016b
2023-03-12T21:05:13.161Z
Question from Code
v2
What does the program print to stderr if the user presses Ctrl+C at the moment when the program is at position B?
#include <signal.h> #include <stdio.h> 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; }
null
null
63c648f85f004bf4898d016b
2023-03-12T21:13:48.381Z
Question from Code
v2
What does the program print to stderr if the user presses Ctrl+C at the moment when the program is at position C?
#include <signal.h> #include <stdio.h> 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; }
null
null
63c648f85f004bf4898d016b
2023-03-19T23:55:42.217Z
General Question
v2
What would we pass in as the type argument for socket() if we wanted to support datagrams? (Use the man page for socket to look this up.)
null
null
null
63c648f85f004bf4898d016b
2023-04-02T15:49:10.294Z
General Question
v2
echo I live at $1 $2 $3. shift echo Now, I live at $0 $1 $2. Suppose I run the script as follows: sh shifter.sh 100 University Ave What does it output?
null
null
null
63c648fa5f004bf4898d017f
2023-01-24T17:31:55.378Z
Help Fix Code
v1
null
int *build_array(char **strs, int size) { int *test; test = malloc(sizeof(int) * size); for (int i = 0; i < size; i ++){ test[i] = strtol(*strs, strs, 10); } }
null
null
63c648fa5f004bf4898d017f
2023-01-24T17:33:03.139Z
Help Fix Code
v1
null
int *build_array(char **strs, int size) { int *test; test = malloc(sizeof(int) * size); for (int i = 0; i < size; i ++){ test[i] = strtol(*strs, strs, 10); } return test; }
It is supposed to convert a string input of arrays into an array of ints
null
63c648fa5f004bf4898d017f
2023-01-24T17:36:17.086Z
Help Fix Code
v1
null
int *build_array(char **strs, int size) { int *test; test = malloc(sizeof(int) * size); for (int i = 0; i < size; i ++){ test[i] = strtol(*strs, strs, 10); } return test; } main(int argc, char **argv){ int *full_array = build_array(&ar[1], argc - 1); return 0; }
This code is supposed to set full_array to an integer array made of the string values inputted from command line.
null
63c648fa5f004bf4898d017f
2023-02-14T23:33:09.378Z
Question from Code
v1
why does my code segmentation fault
int make_post(const User *author, User *target, char *contents) { if (author == NULL || target == NULL) { return 2; } int success = 1; for (int i = 0; i < MAX_FRIENDS; i++) { if (target->friends[i] != NULL && strcmp(target->friends[i]->name, author->name) == 0) { success = 0; } } if (success == 0) { Post *new_post = malloc(sizeof(Post)); strncpy(new_post->author, author->name, strlen(author->name) + 1); strncpy(new_post->contents, contents, strlen(contents) + 1); *(new_post->date) = time(NULL); new_post->next = target->first_post; target->first_post = new_post; } return success; }
null
null
63c648fa5f004bf4898d017f
2023-02-14T23:53:43.182Z
Question from Code
v1
Why does this function segmentation fault
int make_post(const User *author, User *target, char *contents) { if (author == NULL || target == NULL) { return 2; } int success = 1; for (int i = 0; i < MAX_FRIENDS; i++) { if (target->friends[i] != NULL && strcmp(target->friends[i]->name, author->name) == 0) { success = 0; } } if (success == 0) { Post *new_post = malloc(sizeof(Post)); new_post->date = malloc(sizeof(time_t)); strncpy(new_post->author, author->name, strlen(author->name) + 1); strncpy(new_post->contents, contents, strlen(contents) + 1); *(new_post->date) = time(NULL); new_post->next = target->first_post; target->first_post = new_post; } return success; }
null
null
63c648fb5f004bf4898d0184
2023-01-20T05:06:25.264Z
Question from Code
v1
address
int n = 1;
null
null
63c648fb5f004bf4898d0184
2023-01-20T05:07:14.830Z
Explain Code
v1
null
int n = 1; int b = n;
null
null
63c648fb5f004bf4898d0184
2023-01-20T05:07:39.752Z
General Question
v1
address of 1 and 2
null
null
null
63c648fb5f004bf4898d0184
2023-01-20T05:08:22.588Z
Help Write Code
v1
null
null
null
address of line 1 and line 2
63c648fb5f004bf4898d0184
2023-01-20T05:11:51.262Z
Question from Code
v1
result
int a = 1; int *p = &a; printf(%d, p); a = 3; printf(%d, *p); printf(%d, p)
null
null
63c648fd5f004bf4898d0193
2023-02-11T23:59:37.324Z
Help Fix Code
v1
null
/* * From the list pointed to by *user_ptr_del, delete the user * with the given name. * Remove the deleted user from any lists of friends. * * Return: * - 0 on success. * - 1 if a user with this name does not exist. */ int delete_user(const char *name, User **user_ptr_del) { // initialize variables for linked list traversal User *current = *user_ptr_del; User *prev = NULL; // search for the user to delete while (current != NULL && strcmp(current->name, name) != 0) { prev = current; current = current->next; } // if user was not found if (current == NULL) { return 1; } // Remove user from every friend list int i, j; for (i = 0; i < MAX_FRIENDS; i++) { if (current->friends[i] == NULL) { break; } for (j = 0; j < MAX_FRIENDS; j++) { if (current->friends[i]->friends[j] == current) { current->friends[i]->friends[j] = NULL; break; } } } // remove user from list if (prev == NULL) { *user_ptr_del = current->next; } else { prev->next = current->next; } // free dynamically allocated memory for the user's posts Post *post = current->first_post; while (post != NULL) { Post *temp = post; // use a temporary variable post = post->next; free(temp->contents); free(temp); } free(current); // free the user's allocated memory return 0; // return 0 on success }
frees all allocated memory
null
63c648fd5f004bf4898d0198
2023-02-03T21:25:04.988Z
Question from Code
v1
If there any error in the code
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 int greet_len = strlen(argv[1]); // Size of greeting is bigger than 20 if (greet_len >= 19){ strncpy(greeting, argv[1], sizeof(greeting)); greeting[19] = '\0'; } else{ strncpy(greeting, argv[1], sizeof(greeting)); greeting[greet_len] = ' '; strncat(greeting, name, sizeof(greeting) - greet_len - 1); greeting[19] = '\0'; } printf("%s\n", greeting); return 0; }
null
null
63c648fd5f004bf4898d0198
2023-02-03T21:26:46.016Z
Explain Code
v1
null
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 int greet_len = strlen(argv[1]); // Size of greeting is bigger than 20 if (greet_len >= 19){ strncpy(greeting, argv[1], sizeof(greeting)); greeting[19] = '\0'; } else{ strncpy(greeting, argv[1], sizeof(greeting)); greeting[greet_len] = ' '; strncat(greeting, name, sizeof(greeting) - greet_len - 1); greeting[19] = '\0'; } printf("%s\n", greeting); return 0; }
null
null
63c648ff5f004bf4898d01ac
2023-01-24T00:42:21.622Z
Question from Code
v1
what's wrong with the code?
#include <stdio.h> #include <stdlib.h> int main(){ int allocated_memory; allocated_memory = malloc(sizeof(float)); return 0; }
null
null
63c648ff5f004bf4898d01ac
2023-01-24T00:43:37.063Z
Help Fix Code
v1
null
#include <stdio.h> #include <stdlib.h> int main(){ int allocated_memory; allocated_memory = malloc(sizeof(float)); return 0; }
allocate space for allocated_memory
null
63c648ff5f004bf4898d01ac
2023-03-10T19:43:33.506Z
General Question
v2
what are pipes
null
null
null
63c648ff5f004bf4898d01ac
2023-03-10T19:44:18.911Z
General Question
v2
Explain execl
null
null
null
63c648ff5f004bf4898d01ac
2023-03-10T19:45:15.454Z
General Question
v2
Does execl end a program?
null
null
null
63c648ff5f004bf4898d01ac
2023-03-10T19:45:52.407Z
General Question
v2
execl example program
null
null
null
63c648ff5f004bf4898d01ac
2023-03-10T19:48:00.783Z
General Question
v2
pipe write example
null
null
null
63c648ff5f004bf4898d01ac
2023-03-17T02:33:43.911Z
General Question
v2
what random libraries are there?
null
null
null
63c648ff5f004bf4898d01ac
2023-03-17T02:34:54.261Z
General Question
v2
how do I set the RANDMAX for the random()
null
null
null
63c648ff5f004bf4898d01ac
2023-03-17T03:01:10.412Z
General Question
v2
how does fseek work
null
null
null
63c648ff5f004bf4898d01ac
2023-03-17T03:05:28.668Z
General Question
v2
what does Fread return
null
null
null