Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
2
votes
Accepted
how effective would it have been to use an array for the dictionary?
suppose we are to implement speller using an array instead of a hash-table or a trie. … so why not set a maximum size for our array? …
0
votes
2D array of given size
it's generally recommended to minimize your heap usage. another alternative would be creating an array of pointers, perhaps on the stack, and allocating memory for your int arrays on the heap as necessary …
2
votes
Accepted
declaring char array vs malloc
when you declare an array of a certain size, depending on where you declare your array, the memory for it may get allocated on the stack (e.g., if it's declared as a local variable — inside of a function … memory allocated on the stack gets freed automatically as your array (or more generally, local variable) gets out of scope. so you don't have to worry about manually freeing your memory. …
7
votes
Accepted
not fully understanding dynamically sized array in server.c pest
of course needle and haystack both are pointers and thus they both store addresses which are essentially numbers so we can perform arithmetic operations on them.
needle - haystack + 2 + 1
subtract …
3
votes
Accepted
Why can we pass a struct variable to a function by value but not an array?
can say that there is no array parameter type. when you declare the type of a parameter as an array, it actually gets declared to be of the array element's pointer type. … it's often said that arrays decay to pointers. this is actually why when passing an array to a function, only the address of that array is passed. …
1
vote
Struct array not assigning value being set
input_array is an array of pointers to inputs — input_array[counter] evaluates to an input * not an input. accessing input_value through input_array[counter] using the . operator is not actually the correct …
1
vote
Accepted
Help me find the bug in this array code
you have your second for loop nested inside the first one which means that the second for loop is not executed after votecounter[1] to votecounter[4] are initialized to 0, but rather it's executed onc …
0
votes
Accepted
Can I create and initialize arrays of other types the same way I can create and initialize c...
Array names decay to pointers (i.e., if you used the name of an array by itself, then you're using a pointer to the whole array which happens to be also a pointer to the first element in the array). … So str here is mainly a pointer to the whole array, but it also could be a pointer to the first element in the array (i.e., the char 'f' in this case). …
4
votes
about strings and arrays
allocates a chunk of memory, reads the string that the user enters character by character, stores the current character at the appropriate location and, if at some point there's not enough space left in the array … , it reallocates a new array with ~double the size of the older one, copies the contents of the older array into the newer array, frees the older array and the process repeats. …
1
vote
Accepted
Try to sort strings with merge sort
First, this is not a 2D array of strings. It's a 2D array of chars and 1D array of strings. …
0
votes
Accepted
different between pointers and pointer to arrays?
the first element in the array as well. … for the
array. …
1
vote
unable to use a 2d array via function
A function that takes a 2D-array as an argument may have the following prototype
void foo(int arr[][<cols>]);
where <cols> is the number of columns in the array to be passed. … The following piece of code passes a 2D-array to foo (declared above)
int bar[3][3];
foo(bar);
Notice that I'm not passing &bar because that would be a pointer to my 2D-array not my 2D-array itself. …
0
votes
Accepted
How are associative arrays like hash-tables?
A hash-table basically maps keys to values (it basically consists of these two parts — the keys part and the values part). If you used a hash-table in pset6, you'd probably know that you had to implem …
1
vote
Accepted
The difference between the format of houses.js and passengers.js
You can think of HOUSES as an associative array. It contains key/value pairs. …
1
vote
What stuff that's inside array[-1] or array[n + 1]?
In C, there's nothing prevents you from doing such thing as trying to access illegal array indices. … In C, however, if values is an n-element array, then values[-1] starts at sizeof (values[0]) bytes right before the start of values[0]. …