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
⌀ |
---|---|---|---|---|---|---|---|
63c647f55f004bf4898cf82e | 2023-03-14T22:58:13.792Z | General Question | v2 | 1 is equal to true or false | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T09:09:49.813Z | Help Fix Code | v2 | split line "\tgcc -Wall -g -std=gnu99 -o main linked_list.o main.o" by " " and forms an array of strings | char **helper_build_action(char *line){
char **result = malloc(MAXLINE * sizeof(char));
if (result == NULL){
perror("Error occurred during malloc");
exit(1);
}
char *tk = strtok(line, " ");
int i = 0;
tk = strtok(NULL, " ");
while(tk != NULL){
result[i] = tk;
i += 1;
tk = strtok(NULL, " ");
}
result[i] = NULL;
return result;
} | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T09:24:52.903Z | Help Fix Code | v2 | input: line = "\tgcc -Wall -g -std=gnu99 -o main linked_list.o main.o"
desired output = ["gcc", "-Wall", "-g", "-std=gnu99", "-o", "main", "linked_list.o", "main.o", NULL] | char **helper_build_action(char *line){
char **result = malloc(MAXLINE * sizeof(char));
if (result == NULL){
perror("Error occurred during malloc");
exit(1);
}
char *tk = strtok(line, "\t");
int i = 0;
tk = strtok(NULL, "\t");
while(tk != NULL){
result[i] = strdup(tk);
i += 1;
tk = strtok(NULL, " ");
}
result[i] = NULL;
return result;
}
| null | null |
63c647f55f004bf4898cf82e | 2023-03-15T09:26:30.172Z | Help Fix Code | v2 | Intended Behavior: input: line = "\tgcc -Wall -g -std=gnu99 -o main linked_list.o main.o"
result = ["gcc", "-Wall", "-g", "-std=gnu99", "-o", "main", "linked_list.o", "main.o", NULL] | char **helper_build_action(char *line){
char **result = malloc(MAXLINE * sizeof(char));
if (result == NULL){
perror("Error occurred during malloc");
exit(1);
}
char *tk = strtok(line, "\t");
int i = 0;
tk = strtok(NULL, "\t");
while(tk != NULL){
result[i] = strdup(tk);
i += 1;
tk = strtok(NULL, " ");
}
result[i] = NULL;
return result;
}
| null | null |
63c647f55f004bf4898cf82e | 2023-03-15T10:36:12.810Z | General Question | v2 | what does execvp do | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T11:26:13.271Z | General Question | v2 | how to call stat? | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T15:12:19.483Z | General Question | v2 | what is the difference between perror and fprintf | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T15:28:32.546Z | General Question | v2 | How to use access to determine file existence. | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T15:42:37.736Z | General Question | v2 | how to initialize a variable taking true/false value | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T16:59:34.197Z | General Question | v2 | what is st_mtim in struct stat? | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T18:41:30.616Z | General Question | v2 | Explain WIFEXIT | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T18:56:51.445Z | General Question | v2 | Should child process always use exit(0) at the end? | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T19:08:39.178Z | General Question | v2 | is pid_t int? | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T19:23:18.052Z | General Question | v2 | explain WIFEXITED | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T19:25:24.315Z | General Question | v2 | explain WEXITSTATUS | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-15T19:25:24.647Z | General Question | v2 | explain WEXITSTATUS | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-17T19:40:21.416Z | General Question | v2 | How to generate a random int between 0 to 99 | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-17T19:45:31.804Z | General Question | v2 | what does it mean if a loop header is for (;;) | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-17T19:47:28.121Z | Help Write Code | v2 | null | null | null | Generate a random integer from 0 to 100 |
63c647f55f004bf4898cf82e | 2023-03-17T20:03:48.107Z | General Question | v2 | if I add a signal handler to a file, where do I add it? | null | null | null |
63c647f55f004bf4898cf82e | 2023-03-17T20:44:24.248Z | General Question | v2 | what does setitimer do
| null | null | null |
63c647f55f004bf4898cf82e | 2023-04-05T20:05:56.675Z | General Question | v2 | what is the input of malloc function | null | null | null |
63c647f55f004bf4898cf82e | 2023-04-05T20:23:39.847Z | General Question | v2 | explain strcat | null | null | null |
63c647f55f004bf4898cf82e | 2023-04-05T20:28:31.540Z | General Question | v2 | what will strncat do? | null | null | null |
63c647f55f004bf4898cf82e | 2023-04-05T20:32:44.199Z | General Question | v2 | what is the strlen of "\n" | null | null | null |
63c647f55f004bf4898cf82e | 2023-04-05T20:37:38.981Z | General Question | v2 | what does snprintf do | null | null | null |
63c647f55f004bf4898cf82e | 2023-04-06T01:10:52.091Z | General Question | v2 | asctime(localtime()), what does the return string looks like | null | null | null |
63c647f55f004bf4898cf82e | 2023-04-06T04:24:28.532Z | General Question | v2 | do we need to catch error for free()? | null | null | null |
63c647f55f004bf4898cf82e | 2023-04-06T07:00:55.885Z | General Question | v2 | server program and client program communicate via what? | null | null | null |
63c647f65f004bf4898cf838 | 2023-01-20T17:47:56.538Z | Help Fix Code | v1 | null | \usepackage[margins=2.5]{geometry}
| null | null |
63c647f65f004bf4898cf838 | 2023-01-23T21:49:02.256Z | General Question | v1 | If I have float *x; and float y; how do I increase the amount stored in y by the amount in x?
| null | null | null |
63c647f65f004bf4898cf838 | 2023-01-23T21:53:49.733Z | Help Fix Code | v1 | null |
int main(int argc, char **argv) {
float x = 2.2;
float *y;
y = &x +1
| add the value of x to the value of y | null |
63c647f65f004bf4898cf838 | 2023-01-30T21:45:11.994Z | Help Fix Code | v1 | null | #include <stdio.h>
#include <stdlib.h>
// TODO: Implement a helper named check_permissions that matches the prototype below.
int check_permissions(char *permission, char *file) {
for (int i = 0; i < 9; i++) {
if (permission[i] != file[i]) {
return 1;
}
} return 0;
}
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.
int loop = (argc == 2);
printf("loop:%d", loop);
int check_size = strtol(argv[1], NULL, 10);
char perm[10];
int size, count;
count = 0;
int cycle = 0;
scanf("%*s %*s");
while (scanf("%s %*d %*s %*s %d %*s %*s %*s %*s", perm, &size) == 2){
printf("cycle :%d", cycle); cycle++;
if (perm[0] == '-') {
printf("cycle :%d", cycle); cycle++;
if (size > check_size){
if (loop ==0){
count++;
} else {
if (check_permissions(&perm[1], argv[2])==0){
count++;
}
}
}
}
}
printf("cycle :%d", cycle); cycle++;
printf("%d\n", count);
return 0;
} | return a count of ls -l file sizes larger than value parameter provided. If second parameter is 9 element permissions, the count is of files larger than first parameter that also match permissions. | null |
63c647f65f004bf4898cf838 | 2023-01-30T21:51:20.234Z | Help Fix Code | v1 | null | #include <stdio.h>
#include <stdlib.h>
// TODO: Implement a helper named check_permissions that matches the prototype below.
int check_permissions(char *permission, char *file) {
for (int i = 0; i < 9; i++) {
if (permission[i] != file[i]) {
return 1;
}
} return 0;
}
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.
int loop = (argc == 3);
printf("loop:%d", loop);
int check_size = strtol(argv[1], NULL, 10);
char perm[10];
int size, count;
count = 0;
int cycle = 0;
scanf("%*s %*s");
while (scanf("%s %*d %*s %*s %d %*s %*s %*s %*s", perm, &size) == 2){
printf("cycle :%d", cycle); cycle++;
if (perm[0] == '-') {
printf("cycle :%d", cycle); cycle++;
if (size > check_size){
if (loop ==0){
count++;
} else {
if (check_permissions(&perm[1], argv[2])==0){
count++;
}
}
}
}
}
printf("cycle :%d", cycle); cycle++;
printf("%d\n", count);
return 0;
} | return count of files larger than given parameter | null |
63c647f65f004bf4898cf838 | 2023-02-03T22:18:04.327Z | Help Fix Code | v1 | null | #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 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() changes s to
the string "fun" and returns 5.
*/
int truncate(char *s, int n) {
int val_length = strlen(s);
if (val_length <= n){
return 0;
}
s[n] = '\0';
return val_length - n;
}
int main(int argc, char **argv) {
/* Do not change the main function */
if (argc != 3) {
fprintf(stderr, "Usage: truncate number string\n");
return 1;
}
int amt = strtol(argv[1], NULL, 10);
char *target = argv[2];
int soln_val = truncate(target, amt);
printf("%d %s\n", soln_val, target);
return 0;
} | it should return pow 3 when run with ./o powder 3
| null |
63c647f95f004bf4898cf851 | 2023-01-23T19:47:31.213Z | General Question | v1 | Assign a dynamically allocate char* array of length 4 to variable called last_names | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T19:51:08.380Z | General Question | v1 | How to write a for loop in c for an array | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T19:58:31.200Z | General Question | v1 | allocate a character array of length 20 for each element of the array pointed to by last_names | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T20:01:55.140Z | Question from Code | v1 | How do I allocate a character array of length 20 for each element of the array pointed to by last_names? | #include <stdlib.h>
#include <stdio.h>
int main() {
char **last_names;
// Assign a dynamically allocated char * array of length 4 to last_names.
// Then, allocate a character array of length 20 for each element of the array
// pointed to by last_names.
last_names = (char **) malloc(sizeof(char*)*4);
for (int i=0; i <= sizeof(last_names); ++i)
{
last_names[i] = (char *) malloc(20 * sizeof(char));
}
return 0;
} | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T20:12:17.491Z | General Question | v1 | allocate space on the heap for an array of 12 floats and assign it to the pointer monthly_rainfall | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T20:13:05.936Z | General Question | v1 | rainfall has been dynamically allocated space for a floating point number and initialized in hidden code.
Add 7.6 to the amount currently stored in the space rainfall points to.
| null | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T20:14:19.832Z | General Question | v1 | Add 7.6 to the amount currently stored in the space rainfall points to.
| null | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T20:15:39.566Z | General Question | v1 | Increase the amount currently stored in total_rain by the amount stored in the space pointed to by rainfall. | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T20:18:06.765Z | General Question | v1 | set the allocated_amount variable to the exact amount of space that should be allocated and pointed to by float *rainfall | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T20:20:00.684Z | Question from Code | v1 | Assign the amount in rain_today to the space rainfall points to. | #include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
float *rainfall;
float rain_today;
// rainfall has been dynamically allocated space for a floating point number.
// Both rainfall and rain_today have been initialized in hidden code.
// Assign the amount in rain_today to the space rainfall points to.
return 0;
}
| null | null |
63c647f95f004bf4898cf851 | 2023-01-23T20:25:31.830Z | Help Fix Code | v1 | null | #include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
float *rainfall;
float rain_today;
// rainfall has been dynamically allocated space for a floating point number.
// Both rainfall and rain_today have been initialized in hidden code.
// Assign the amount in rain_today to the space rainfall points to.
rain_today = *rainfall;
return 0;
}
| rain_today should be used. | null |
63c647f95f004bf4898cf851 | 2023-01-23T20:31:32.366Z | General Question | v1 | /* Returns the sum of two integers in the string input_line.
input_line is a string containing two integers separated by one
or more spaces.
Assume that the string will not be more than 20 characters
long and that it contains two integers separated only by whitespace.
There may also be spaces before the first integer
and/or after the last, but there won't be any other characters
in the string.
For example, get_sum(" 123 5 ") should return the integer 128,
and get_sum("-14 30") should return the integer 16.
Hint: use strtol().
*/ | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T21:33:06.583Z | General Question | v1 | return the sum of two integers in the string input_line using strtol(). | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T21:34:25.773Z | Help Fix Code | v1 | null | * Returns the sum of two integers in the string input_line.
input_line is a string containing two integers separated by one
or more spaces.
Assume that the string will not be more than 20 characters
long and that it contains two integers separated only by whitespace.
There may also be spaces before the first integer
and/or after the last, but there won't be any other characters
in the string.
For example, get_sum(" 123 5 ") should return the integer 128,
and get_sum("-14 30") should return the integer 16.
Hint: use strtol().
*/
int get_sum(const char *input_line) {
// Submitted code below
int a = strtol(input_line, &input_line, 10);
int b = strtol(input_line, &input_line, 10);
printf("%d", a + b);
return 0;
// Submitted code above
}
// Submitted code below | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T21:36:37.332Z | General Question | v1 | Given three variables with hidden integer values, compare their values for uniqueness and print one of the following statements:
- "none unique" (if all variables share the same value)
- "some unique" (if exactly two variables share the same value)
- "all unique" (if there are no duplicates) | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-23T22:12:55.480Z | General Question | v1 | Write a for loop that prints the integers from 1 to 10 with spaces separating the values.
| null | null | null |
63c647f95f004bf4898cf851 | 2023-01-25T21:04:05.798Z | Question from Code | v1 | Why am I getting a segmentation fault? |
#include <stdlib.h>
#include <stdio.h>
/*
* Define a function void fib(...) below. This function takes parameter n
* and generates the first n values in the Fibonacci sequence. Recall that this
* sequence is defined as:
* 0, 1, 1, 2, 3, 5, ... , fib[n] = fib[n-2] + fib[n-1], ...
* The values should be stored in a dynamically-allocated array composed of
* exactly the correct number of integers. The values should be returned
* through a pointer parameter passed in as the first argument.
*
* See the main function for an example call to fib.
* Pay attention to the expected type of fib's parameters.
*/
/* Write your solution here */
void fib(int** fib_seq, int count) {
*fib_seq = malloc(count * sizeof(int));
if (count == 0) {
return;
}
if (count > 0) {
(*fib_seq)[0] = 0;
}
if (count > 1) {
(*fib_seq)[1] = 1;
}
for (int i=2; i < count; i++) {
(*fib_seq)[i] = (*fib_seq)[i-2] + (*fib_seq)[i-1];
}
return;
}
int main(int argc, char **argv) {
/* do not change this main function */
int count = strtol(argv[1], NULL, 10);
int *fib_sequence;
fib(&fib_sequence, count);
for (int i = 0; i < count; i++) {
printf("%d ", fib_sequence[i]);
}
free(fib_sequence);
return 0;
} | null | null |
63c647f95f004bf4898cf851 | 2023-01-25T21:05:50.428Z | Help Fix Code | v1 | null |
#include <stdlib.h>
#include <stdio.h>
/*
* Define a function void fib(...) below. This function takes parameter n
* and generates the first n values in the Fibonacci sequence. Recall that this
* sequence is defined as:
* 0, 1, 1, 2, 3, 5, ... , fib[n] = fib[n-2] + fib[n-1], ...
* The values should be stored in a dynamically-allocated array composed of
* exactly the correct number of integers. The values should be returned
* through a pointer parameter passed in as the first argument.
*
* See the main function for an example call to fib.
* Pay attention to the expected type of fib's parameters.
*/
/* Write your solution here */
void fib(int** fib_seq, int count) {
*fib_seq = malloc(count * sizeof(int));
if (count == 0) {
return;
}
if (count > 0) {
(*fib_seq)[0] = 0;
}
if (count > 1) {
(*fib_seq)[1] = 1;
}
for (int i=2; i < count; i++) {
(*fib_seq)[i] = (*fib_seq)[i-2] + (*fib_seq)[i-1];
}
return;
}
int main(int argc, char **argv) {
/* do not change this main function */
int count = strtol(argv[1], NULL, 10);
int *fib_sequence;
fib(&fib_sequence, count);
for (int i = 0; i < count; i++) {
printf("%d ", fib_sequence[i]);
}
free(fib_sequence);
return 0;
} | no segmentation fault
| null |
63c647f95f004bf4898cf851 | 2023-01-25T21:43:24.126Z | Help Fix Code | v1 | null | #include <stdlib.h>
#include <stdio.h>
/*
* Define a function void fib(...) below. This function takes parameter n
* and generates the first n values in the Fibonacci sequence. Recall that this
* sequence is defined as:
* 0, 1, 1, 2, 3, 5, ... , fib[n] = fib[n-2] + fib[n-1], ...
* The values should be stored in a dynamically-allocated array composed of
* exactly the correct number of integers. The values should be returned
* through a pointer parameter passed in as the first argument.
*
* See the main function for an example call to fib.
* Pay attention to the expected type of fib's parameters.
*/
/* Write your solution here */
void fib(int **sequence, int num){
*sequence = malloc(sizeof(int) * num);
int *sequence2 = *sequence;
if (num > 0) {
sequence2[0] = 0;
if (num > 1) {
sequence2[1] = 1;
for (int i = 2; i < num; i++){
sequence2[i] = sequence2[i - 1] + sequence2[i - 2];
}
}
}
}
int main(int argc, char **argv) {
/* do not change this main function */
int count = strtol(argv[1], NULL, 10);
int *fib_sequence;
fib(&fib_sequence, count);
for (int i = 0; i < count; i++) {
printf("%d ", fib_sequence[i]);
}
free(fib_sequence);
return 0;
} | no segmentation error | null |
63c647f95f004bf4898cf851 | 2023-01-25T22:49:36.528Z | General Question | v1 | Define a string literal named tasty with the value "doughnut". | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-25T22:55:02.957Z | General Question | v1 | Set the value of delicious (which has already been declared) to "ice cream".
| null | null | null |
63c647f95f004bf4898cf851 | 2023-01-25T22:57:12.367Z | General Question | v1 | The string sweet has been declared on the heap and has space for 20 characters.
Set the value of sweet to "tiramisu" without changing its address. | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-25T22:59:44.674Z | General Question | v1 | 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 | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-26T01:21:58.462Z | General Question | v1 | Define a string literal called season that has the value
"winter".
| null | null | null |
63c647f95f004bf4898cf851 | 2023-01-26T01:25:29.535Z | General Question | v1 | 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".
| null | null | null |
63c647f95f004bf4898cf851 | 2023-01-26T01:26:55.050Z | General Question | v1 | Create a node struct with the following struct members:
- value, an integer
- next, a pointer to another node
Typedef your structure as Node.
| null | null | null |
63c647f95f004bf4898cf851 | 2023-01-26T01:27:45.634Z | General Question | v1 | 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. | null | null | null |
63c647f95f004bf4898cf851 | 2023-01-26T01:32:00.863Z | Question from Code | v1 | 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. | typedef struct node {
int value;
struct node *next;
} Node;
int main(int argc, char **argv) {
Node *front; // pointer to first node of the list
// Submitted code below
while (curr != NULL) {
printf("%d \n", curr->value);
curr = curr->next;
}
// Submitted code above
return 0;
}
// Submitted code below | null | null |
63c647f95f004bf4898cf851 | 2023-01-26T01:32:37.598Z | Help Fix Code | v1 | null | typedef struct node {
int value;
struct node *next;
} Node;
int main(int argc, char **argv) {
Node *front; // pointer to first node of the list
// Submitted code below
while (curr != NULL) {
printf("%d \n", curr->value);
curr = curr->next;
}
// Submitted code above
return 0;
}
// Submitted code below | 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. | null |
63c647f95f004bf4898cf851 | 2023-01-26T01:39:02.111Z | Help Fix Code | v1 | null | #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 | Set the value of delicious (which has already been declared) to "ice cream". | null |
63c647f95f004bf4898cf851 | 2023-01-26T01:40:13.328Z | Help Fix Code | v1 | null | #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 | Set the value of delicious (which has already been declared) to "ice cream".
| null |
63c647f95f004bf4898cf851 | 2023-01-26T01:41:41.472Z | Help Fix Code | v1 | null | #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 | Set the value of delicious (which has already been declared) to "ice cream".
| null |
63c647f95f004bf4898cf851 | 2023-01-26T01:42:25.408Z | Help Fix Code | v1 | null | #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 | Set the value of delicious (which has already been declared) to "ice cream".
| null |
63c647f95f004bf4898cf851 | 2023-01-26T01:43:10.071Z | Help Fix Code | v1 | null | #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 | Set the value of delicious (which has already been declared) to "ice cream".
| null |
63c647f95f004bf4898cf851 | 2023-01-26T01:47:43.429Z | Help Fix Code | v1 | null | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct contact {
char name[30];
int phone_number;
char address[30];
};
// update_contact goes here
// Submitted code below
// Submitted code above
int main(int argc, char **argv) {
struct contact friend;
// set initial values for friend
strcpy(friend.name, "Jane Doe");
friend.phone_number = 377177377;
strcpy(friend.address, "3771 University Avenue");
char *name;
int number;
char *address;
// in hidden code set values for these 3 variables
// call update_contact to change the values in friend
update_contact(&friend, name, number, address);
return 0;
} | Given the following program, write the function update_contact which takes a pointer to the struct contact, a new name, a new number, and a new address to change the struct’s members. Look at the function call for the order of arguments and appropriate types. | null |
63c647f95f004bf4898cf851 | 2023-01-26T01:56:49.710Z | Help Fix Code | v1 | null | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct contact {
char name[30];
int phone_number;
char address[30];
};
// update_contact goes here
// Submitted code below
void update_contact(struct *contact friend, char name, int number, char address) {
strcpy(friend.name = name);
friend.number = number;
strcpy(friend.address = address);
}
// Submitted code above
int main(int argc, char **argv) {
struct contact friend;
// set initial values for friend
strcpy(friend.name, "Jane Doe");
friend.phone_number = 377177377;
strcpy(friend.address, "3771 University Avenue");
char *name;
int number;
char *address;
// in hidden code set values for these 3 variables
// call update_contact to change the values in friend
update_contact(&friend, name, number, address);
return 0;
}
// Submitted code below | Given the following program, write the function update_contact which takes a pointer to the struct contact, a new name, a new number, and a new address to change the struct’s members. Look at the function call for the order of arguments and appropriate types.
| null |
63c647f95f004bf4898cf851 | 2023-01-26T01:59:52.494Z | Help Fix Code | v1 | null | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct contact {
char name[30];
int phone_number;
char address[30];
};
// update_contact goes here
// Submitted code below
void update_contact(struct *contact friend, char *name, int *number, char *address) {
strcpy(friend.name = name);
friend.phone_number = number;
strcpy(friend.address = address);
}
// Submitted code above
int main(int argc, char **argv) {
struct contact friend;
// set initial values for friend
strcpy(friend.name, "Jane Doe");
friend.phone_number = 377177377;
strcpy(friend.address, "3771 University Avenue");
char *name;
int number;
char *address;
// in hidden code set values for these 3 variables
// call update_contact to change the values in friend
update_contact(&friend, name, number, address);
return 0;
}
// Submitted code below | Given the following program, write the function update_contact which takes a pointer to the struct contact, a new name, a new number, and a new address to change the struct’s members. Look at the function call for the order of arguments and appropriate types.
| null |
63c647f95f004bf4898cf851 | 2023-01-26T02:10:14.124Z | Help Fix Code | v1 | null | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct contact {
char name[30];
int phone_number;
char address[30];
};
// update_contact goes here
// Submitted code below
void update_contact(struct *contact friend, char *name, int number, char *address) {
strcpy(friend.name = name);
friend.phone_number = number;
strcpy(friend.address = address);
}
// Submitted code above
int main(int argc, char **argv) {
struct contact friend;
// set initial values for friend
strcpy(friend.name, "Jane Doe");
friend.phone_number = 377177377;
strcpy(friend.address, "3771 University Avenue");
char *name;
int number;
char *address;
// in hidden code set values for these 3 variables
// call update_contact to change the values in friend
update_contact(&friend, name, number, address);
return 0;
} | write the function update_contact which takes a pointer to the struct contact, a new name, a new number, and a new address to change the struct’s members | null |
63c647f95f004bf4898cf851 | 2023-01-26T02:14:39.487Z | Help Fix Code | v1 | null | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct contact {
char name[30];
int phone_number;
char address[30];
};
// update_contact goes here
// Submitted code below
void update_contact(struct *contact c, char new_name, int new_number, char new_address) {
strcpy(c.name = new_name);
c.phone_number = new_number;
strcpy(c.address = new_address);
}
// Submitted code above
int main(int argc, char **argv) {
struct contact friend;
// set initial values for friend
strcpy(friend.name, "Jane Doe");
friend.phone_number = 377177377;
strcpy(friend.address, "3771 University Avenue");
char *name;
int number;
char *address;
// in hidden code set values for these 3 variables
// call update_contact to change the values in friend
update_contact(&friend, name, number, address);
return 0;
}
// Submitted code below | write the function update_contact which takes a pointer to the struct contact, a new name, a new number, and a new address to change the struct’s members. Look at the function call for the order of arguments and appropriate types.
| null |
63c647f95f004bf4898cf851 | 2023-01-26T02:18:12.884Z | Help Fix Code | v1 | null | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct contact {
char name[30];
int phone_number;
char address[30];
};
// update_contact goes here
// Submitted code below
void update_contact(struct *contact c, char new_name, int new_number, char new_address) {
strcpy(c->name = new_name);
(*c).phone_number = new_number;
strcpy(c->address = new_address);
}
// Submitted code above
int main(int argc, char **argv) {
struct contact friend;
// set initial values for friend
strcpy(friend.name, "Jane Doe");
friend.phone_number = 377177377;
strcpy(friend.address, "3771 University Avenue");
char *name;
int number;
char *address;
// in hidden code set values for these 3 variables
// call update_contact to change the values in friend
update_contact(&friend, name, number, address);
return 0;
}
// Submitted code below | Given the following program, write the function update_contact which takes a pointer to the struct contact, a new name, a new number, and a new address to change the struct’s members. Look at the function call for the order of arguments and appropriate types.
| null |
63c647f95f004bf4898cf851 | 2023-01-26T02:20:33.573Z | Help Fix Code | v1 | null | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct contact {
char name[30];
int phone_number;
char address[30];
};
// update_contact goes here
// Submitted code below
void update_contact(struct contact c, char *new_name, int new_number, char *new_address) {
strcpy(c->name,new_name);
(*c).phone_number = new_number;
strcpy(c->address,new_address);
}
// Submitted code above
int main(int argc, char **argv) {
struct contact friend;
// set initial values for friend
strcpy(friend.name, "Jane Doe");
friend.phone_number = 377177377;
strcpy(friend.address, "3771 University Avenue");
char *name;
int number;
char *address;
// in hidden code set values for these 3 variables
// call update_contact to change the values in friend
update_contact(&friend, name, number, address);
return 0;
}
// Submitted code below | Given the following program, write the function update_contact which takes a pointer to the struct contact, a new name, a new number, and a new address to change the struct’s members. Look at the function call for the order of arguments and appropriate types. | null |
63c647f95f004bf4898cf851 | 2023-02-13T17:01:17.977Z | Question from Code | v1 | What will this declaration line become after the program has passed through the C pre-processor? | #include <stdio.h>
#define MAXNAME = 32;
#declaration
char name[MAXNAME];
int main() {
#ifdef MACRO
printf("%d\n", MACRO);
#endif
return 0;
}
| null | null |
63c647f95f004bf4898cf851 | 2023-02-13T17:12:54.370Z | General Question | v1 | Tell me about the C preprocessor
| null | null | null |
63c647fa5f004bf4898cf85b | 2023-01-22T07:17:55.676Z | General Question | v1 | how can equality of two characters be verified?
| null | null | null |
63c647fa5f004bf4898cf85b | 2023-01-22T07:19:35.126Z | General Question | v1 | how can a char be converted to an int?
| null | null | null |
63c647fa5f004bf4898cf85b | 2023-01-22T07:20:30.544Z | Explain Code | v1 | null | int size = (int) argv[1]; | null | null |
63c647fa5f004bf4898cf85b | 2023-02-14T22:53:53.964Z | General Question | v1 | How do I print the contents of a file line by line to standard output?
| null | null | null |
63c647fa5f004bf4898cf860 | 2023-01-27T00:24:58.743Z | Help Fix Code | v1 | null | 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 + term2;
(*array[i]) = next;
term1 = term2;
term2 = next;
}
}
}
int main(int argc, char **argv) {
/* do not change this main function */
int count = strtol(argv[1], NULL, 10);
int *fib_sequence;
fib(&fib_sequence, count);
for (int i = 0; i < count; i++) {
printf("%d ", fib_sequence[i]);
}
free(fib_sequence);
return 0;
} | store up to n fibonacci numbers in a dynamically allocated array and print each element | null |
63c647fa5f004bf4898cf860 | 2023-02-03T07:23:34.942Z | General Question | v1 | how do i truncate a string
| null | null | null |
63c647fa5f004bf4898cf860 | 2023-02-03T08:02:13.188Z | Question from Code | v1 | what is wrong with my code? | 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;
} | null | null |
63c647fa5f004bf4898cf860 | 2023-02-03T20:11:59.396Z | General Question | v1 | Use strcat to concatenate a space into a string | null | null | null |
63c647fa5f004bf4898cf860 | 2023-02-10T06:35:06.477Z | General Question | v1 | how do I read an int from 4 bytes in a binary file | null | null | null |
63c647fa5f004bf4898cf860 | 2023-02-10T06:45:44.802Z | Help Fix Code | v1 | null | 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);
} | I want to read 4 byte integers from file metadata | null |
63c647fa5f004bf4898cf860 | 2023-02-10T06:48:46.385Z | Question from Code | v1 | I want to read integers from byte offsets 10-13, 18-21 and 22-25 | 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);
} | null | null |
63c647fa5f004bf4898cf860 | 2023-02-10T07:13:05.794Z | General Question | v1 | initialize multiple pointers using a for loop | null | null | null |
63c647fa5f004bf4898cf860 | 2023-02-14T08:01:25.711Z | Question from Code | v1 | why is demo_user not defined? | int main() {
struct user demo_user;
int result = create_user("Dario", &&demo_user);
printf("%d\n", result);
return 0;
} | null | null |
63c647fa5f004bf4898cf860 | 2023-02-14T08:12:50.010Z | Question from Code | v1 | why am i getting a segmentation fault? | int create_user(const char *name, User **user_ptr_add) {
User *curr = *user_ptr_add;
while (curr->next != NULL) {
if (curr->name == name) {
return 1;
}
curr = curr->next;
}
if (strlen(name) + 1 > 32) {
return 2;
}
User new_user;
strcpy(new_user.name, name);
new_user.next = NULL;
curr->next = &new_user;
return 0;
} | null | null |
63c647fa5f004bf4898cf860 | 2023-02-14T08:29:07.341Z | Question from Code | v1 | why am i getting a segmentation fault? | int create_user(const char *name, User **user_ptr_add) {
User *curr = malloc(sizeof(User));
curr = *user_ptr_add;
while (curr->next != NULL) {
if (curr->name == name) {
return 1;
}
curr = curr->next;
}
if (strlen(name) + 1 > 32) {
return 2;
}
User *new_user = malloc(sizeof(User));
strncpy(new_user->name, name, 31);
new_user->next = NULL;
curr->next = new_user;
return 0;
} | null | null |
63c647fa5f004bf4898cf860 | 2023-02-14T08:34:55.057Z | Question from Code | v1 | why am i getting a segmentation fault? | int create_user(const char *name, User **user_ptr_add) {
User *curr = *user_ptr_add;
while (curr->next != NULL) {
if (curr->name == name) {
return 1;
}
curr = curr->next;
}
if (strlen(name) + 1 > 32) {
return 2;
}
User *new_user = malloc(sizeof(User));
strncpy(new_user->name, name, 31);
new_user->next = NULL;
curr->next = new_user;
return 0;
} | null | null |
63c647fa5f004bf4898cf860 | 2023-02-14T18:14:51.708Z | General Question | v1 | how do I insert an element into the first empty spot of an array? | null | null | null |
63c647fa5f004bf4898cf860 | 2023-02-15T03:09:52.992Z | Question from Code | v1 | why am i getting a segmentation fault
| int make_friends(const char *name1, const char *name2, User *head) {
if (strcmp(name1, name2) == 0) {
return 3;
}
User *user1 = malloc(sizeof(User));
User *user2 = malloc(sizeof(User));
user1 = find_user(name1, head);
user2 = find_user(name2, head);
if (user1 == NULL || user2 == NULL) {
return 4;
}
int u1_friends_w_u2 = 0;
int u2_friends_w_u1 = 0;
for (int i = 0; i < 10; i++) {
if (user1->friends[i] == user2) {
u1_friends_w_u2 = 1;
}
}
for (int i = 0; i < 10; i++) {
if (user2->friends[i] == user1) {
u2_friends_w_u1 = 1;
}
}
if (u1_friends_w_u2 == 1 && u2_friends_w_u1 == 1) {
return 1;
}
// By now the check for if they are already friends has happened, so this should test not friends and if at max capcity
if (sizeof(user1->friends) == 10 || sizeof(user2->friends) == 10) {
return 2;
}
for (int i = 0; i < 10; i++) {
if (user1->friends[i] == NULL) {
user1->friends[i] = user2;
break;
}
}
for (int i = 0; i < 10; i++) {
if (user2->friends[i] == NULL) {
user2->friends[i] = user1;
break;
}
}
return 0;
}
| null | null |
63c647fa5f004bf4898cf860 | 2023-02-15T03:18:26.201Z | Question from Code | v1 | why am i getting a segmentation fault | int make_friends(const char *name1, const char *name2, User *head) {
if (strcmp(name1, name2) == 0) {
return 3;
}
User *user1 = malloc(sizeof(User));
User *user2 = malloc(sizeof(User));
user1 = find_user(name1, head);
user2 = find_user(name2, head);
if (user1 == NULL || user2 == NULL) {
return 4;
}
int u1_friends_w_u2 = 0;
int u1_friend_counter = 0;
int u2_friends_w_u1 = 0;
int u2_friend_counter = 0;
for (int i = 0; i < 10; i++) {
if (user1->friends[i] == user2) {
u1_friends_w_u2 = 1;
} else if (user1->friends[i] != NULL) {
u1_friend_counter++;
}
}
for (int i = 0; i < 10; i++) {
if (user2->friends[i] == user1) {
u2_friends_w_u1 = 1;
} else if (user2->friends[i] != NULL) {
u2_friend_counter++;
}
}
if (u1_friends_w_u2 == 1 && u2_friends_w_u1 == 1) {
return 1;
}
// By now the check for if they are already friends has happened, so this should test not friends and if at max capcity
if (u1_friend_counter == 10 || u2_friend_counter == 10) {
return 2;
}
for (int i = 0; i < 10; i++) {
if (user1->friends[i] == NULL) {
user1->friends[i] = user2;
break;
}
}
for (int i = 0; i < 10; i++) {
if (user2->friends[i] == NULL) {
user2->friends[i] = user1;
break;
}
}
return 0;
} | null | null |
63c647fa5f004bf4898cf860 | 2023-02-15T03:46:40.447Z | Question from Code | v1 | why am i getting a segmentation fault
| int make_friends(const char *name1, const char *name2, User *head) {
if (strcmp(name1, name2) == 0) {
return 3;
}
User *user1 = find_user(name1, head);
User *user2 = find_user(name2, head);
if (user1 == NULL || user2 == NULL) {
return 4;
}
int u1_friends_w_u2 = 0;
int u1_friend_counter = 0;
int u2_friends_w_u1 = 0;
int u2_friend_counter = 0;
for (int i = 0; i < 10; i++) {
if (user1->friends[i] == user2) {
u1_friends_w_u2 = 1;
} else if (user1->friends[i] != NULL) {
u1_friend_counter++;
}
}
for (int i = 0; i < 10; i++) {
if (user2->friends[i] == user1) {
u2_friends_w_u1 = 1;
} else if (user2->friends[i] != NULL) {
u2_friend_counter++;
}
}
if (u1_friends_w_u2 == 1 && u2_friends_w_u1 == 1) {
return 1;
}
// By now the check for if they are already friends has happened, so this should test not friends and if at max capcity
if (u1_friend_counter == 10 || u2_friend_counter == 10) {
return 2;
}
for (int i = 0; i < 10; i++) {
if (user1->friends[i] == NULL) {
user1->friends[i] = user2;
break;
}
}
for (int i = 0; i < 10; i++) {
if (user2->friends[i] == NULL) {
user2->friends[i] = user1;
break;
}
}
return 0;
} | null | null |
63c647fa5f004bf4898cf860 | 2023-02-15T05:55:17.095Z | General Question | v1 | how to read ascii art | null | null | null |
63c647fa5f004bf4898cf860 | 2023-02-15T07:26:03.965Z | General Question | v1 | how to null terminate a string resulting from strncpy | null | null | null |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.