Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Can someone tell me how should I do to allocate every v[i].word and next with NULL?
Struct hash{
Char*word;
Hash*next;
}*v[10];
Make a for loop, let it iterate from i = 0 to 9. In each iteration, allocate one struct hash and point v[i] to it. Afterwards, initialize *v[i] as needed. Don't forget to check if malloc() failed.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 days ago.
Improve this question
I have declared an array of vowels and is trying to compare the input string with this vowel array to count the number of vowels. It doesn't seem working. The output seems to be the multiple of input string and 5.
How to fix this?
vowels="aeiou"
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
can I use post-increment in a function return in C like this?
int meta_solve() {
//some codes
return metaData[head++]; //head is global variable
}
I asking this question because it showing the different results on windows and mac. thanks for your attention. have a great day!
Yes, that will work.
The return will not happen until the expression metaData[head++] is fully evaluated so the (global) variable head is incremented before the function returns.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I'm currently making this program as an activity in class. There's an error popping up when I called the struct inside my main(). I'm posting a picture of the code and where DevC++ was saying where the error is:here's the code
studentRecord[5]; is like doing int[5];.
That will not work.
Provide a variable name.
studentRecord hi[5];
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am analyzing a C code that I have been given and I came across this block:
for (k=0; k<m; k++)
{
//Perform some calculation and assign result to
//A[k].
if (A[k]!=A[k])
{
exception=1;
}
}
I have performed runs of the code where exception does turn out to be one, but I can't seem to understand how two array indices can contain different numbers! Is that something to do with machine precision? Thank you!
You might want to check whether the A[] array is allocated sufficient amount of memory: it should have 'm' elements allocated at least. If everything is OK, check the sizes of other arrays allocated in your program. The phenomenon that you've encountered looks like some memory allocation error.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
some_struct = some_function; //some_function returns a pointer to an instance of a struct
some_struct->num = 8; //num is an int
The second line creates a segmentation fault, when I try to use gdb with the p some_struct->num command, it says Cannot access memory at address 0x0
How do I set the value of some_struct->num without creating a segmentation fault?
Your function is returning a NULL pointer. Make sure it returns valid memory for a some_struct type.