Linked Questions

1 vote
2 answers
22k views

I have an array called numbers and I want to test if a certain number is included in that array. void loop(){ if (arrayIncludeElement(numbers, mynumber)){ // Do something } else { // Do ...
Emil Bonne Kristiansen's user avatar
11 votes
2 answers
4k views

Let's say I have a function like: template<typename It, typename Cmp> void mysort( It begin, It end, Cmp cmp ) { std::sort( begin, end, cmp ); } When I compile this using -finstrument-...
ricky116's user avatar
  • 784
0 votes
4 answers
5k views

#include <stdio.h> int main() { int x[] = {22, 8, 87, 76, 45, 43, 34, 13, 51, 15}; int count = 0; while (x[count] != '\0') { count++; } printf("%d", count); return 0; } I cannot ...
user587389's user avatar
0 votes
4 answers
9k views

I dont know why I have this problem right now! error: request for member 'size' in 'isbn', which is of non-class type 'int*' I am trying to get how many elements (integers) are in isbn. class Book{ ...
Rinor Ajdini's user avatar
0 votes
6 answers
3k views

What is the difference between these two declarations? int myints[5]; array<int,5> myints; If I use the first declarations and the function size(), there will be a error "Member reference base ...
Coleman Tung's user avatar
6 votes
1 answer
1k views

I know defining an array in C is not possible with variable length, but what about just declaring it? #include <stdio.h> int main () { int num = 5; int array[num]; printf("%d\n",...
user avatar
2 votes
3 answers
2k views

I'm a novice in C and I need a structure to pass constant two-dimensional arrays to function as one parameter. I want to make this const int a_size_x = 20; const int a_size_y = 30; const int ...
Paul the Hedgehog's user avatar
1 vote
1 answer
3k views

I can get the sizeof an object in an array in a local function: int xa[] = {3,5}; printf("Sizeof: %zu\n", sizeof(xa)); Sizeof: 8 But if I pass it to a function, I get a warning: void ...
David542's user avatar
  • 112k
2 votes
1 answer
3k views

I am trying to create a 2D array by a for loop but I get some garbage random numbers code: unsigned int i, j; int matrix[10][10];//={{},{}}; for (i = 0; i < sizeof(matrix[i])/sizeof(int); i++) { ...
Dariyoush's user avatar
  • 508
1 vote
2 answers
2k views

Can someone help me figure out why this is not working. int main() { int A[100]; for(int i=0; i<A.length; i++) { } return 0; } Here is my error [Error] request for member '...
GiBiT's user avatar
  • 321
-1 votes
1 answer
3k views

I'm taking the CS50 course on edx and I'm supposed to write a code in C that encrypts a message using the Vigenere Cipher. And I did. But the problem is I keep getting buffer overflow. If I use a ...
Cam Moreira's user avatar
3 votes
4 answers
717 views

Considering the code as follows: int i, a_size, s_size, n; char **a; a_size = 100; // examples s_size = 10; a = malloc(a_size * sizeof(char*)); for (int i = 0; i < a_size; i++) a[i] = malloc(...
vdenotaris's user avatar
  • 13.7k
1 vote
2 answers
4k views

I'm having a problem in C when I'm trying to find the largest float of an array, but my largest int works just fine. I think I might be going past the array length but I don't see how it is possible. ...
wzsun's user avatar
  • 425
3 votes
6 answers
484 views

Is this how you guys get size of an array in ANSI-C99? Seems kind of, um clunky coming from higher language. int tests[7]; for (int i=0; i<sizeof(tests)/sizeof(int); i++) { tests[i] = rand(); ...
user697111's user avatar
  • 2,272
1 vote
5 answers
1k views

Hello i am trying to write a function which return the number of elements of the array passed as parameter, the function have to work on an array of any type. I tried this: int nb_elems(void* array) {...
aurelienC's user avatar
  • 1,193

15 30 50 per page
1
4 5
6
7 8
12