Thank you guys, that's exactly what I need!
Type: Posts; User: dpitz
Thank you guys, that's exactly what I need!
I did. Here it's:
#include <stdio.h>
void foo(int **vec)
{
int n = 3;
vec = malloc(n*sizeof(int*));
*vec[0] = 41;
Oops, my bad.
But it's not working yet =P. Actually the black screen closes just after it opens. You think the code is wrong or it's a problem with the compiler?
Thank you claudiu, but I think I didn't get it... I tried this:
#include <stdio.h>
void foo(int **vec)
{
int n = 3;
vec = malloc(n*sizeof(int**));
*vec[0] = 41;
I'm passing an array (pointer) as an argument of a function, but I know the size of the array only inside the function, so I'd need something like this:
#include <stdio.h>
void foo(int *vec)...
It works here, I typed this into main:
char a = enterSectionLetter();
printf("\nChar is: %c", a);
If I execute the program and type A it gives "Char is A".
Your function must return an int, and you return a char.
The "Enter section [A-Y]" is printed not only twice, but as many characters you type plus one (the '\n' character), so it means that each...
Attention, you're using the "=" sign to compare two chars, and using "%d" in the scanf.
Ok, with what I've written until now I can be sure I won't access an uninitialized 'a'. In fact I count the number of elements inserted in each second index to avoid this.
Thank's again.
I think you didn't check your while loop after seeing the printed value of i ^^.
If you choose to convert 10 to base 2 (1010), you'll get i=4, since 1010 has 4 digits. What we're trying to say is...
Add this line above your last while loop and check what it gives:
printf("\ni = %d\n", i);
Now check again your while loop and voila
Thank you, it's really better this way, using another array.
And should I initialize the parameters ('a' in this case) before I start to attribute values? Even if I use realloc there will be some...
Good morning everybody!
I'm working on an application where I have a structure and I'll use its parameters in a bidimensional matrix [n][k], where n is known and k is unknown and might be different...