Linked Questions
176 questions linked to/from How do I determine the size of my array in C?
0 votes
4 answers
685 views
Array becomes larger than declared [duplicate]
I'm writing a function that is supposed to split a string on "-" and return and array containing the parts from the string, so if the string is: 2017-10-23 I want the array to have three elements ...
-1 votes
1 answer
881 views
sizeof(); returns double the value that of specified array in embedded C [duplicate]
[image of an executed code in keil] I've written above code to move an array( msg[ ] ) to Port 0(I'm using Keil µvision), in which 'unsigned int y' gets the size of the array and displays it to Port 1(...
0 votes
3 answers
1k views
C++ passing array without giving size. Other function to calc array size [duplicate]
I want to pass an array as a parameter. I want the other function to calculate the array size. So array size is not passed as a parameter. How do I do this? #include <stdio.h> #include <...
0 votes
2 answers
448 views
Char array Segmentation fault [duplicate]
I am just playing around with a simple c code. I want to print all the days string in the days array pointer. However I am running to segmentation fault. The problem lies in the for loop. What am I ...
1 vote
1 answer
756 views
2D array of strings get number of columns in a row , division error [duplicate]
I have a problem here. I'm unable to get how many pointers are there in one row of 2D array of strings. Error says: division ‘sizeof (char **) / sizeof (char *)’ does not compute the number of array ...
-2 votes
3 answers
773 views
Array size mismatch - C [duplicate]
I'm writing a program in C to add random numbers to an array. The size of the array is given (say n = 250) and using rand(), I'm generating these numbers (range is 1 to 100). int main() { int n = ...
-1 votes
1 answer
224 views
Using macro to get the array length inside the struct [duplicate]
I have some C code to practice the quick sort. I want to use macro the get the length of the array. The macro works fine in the main() function. But when I use the macro inside the sort function, it ...
0 votes
1 answer
370 views
Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT) is causing my scanf to fail [duplicate]
#include <stdio.h> #include <string.h> #include <stdbool.h> int main(int argc, const char * argv[]) { bool isTrue=true; int nums[50]; for (int i = 0; i<sizeof(nums); i+...
0 votes
1 answer
191 views
OpenGL won't draw within class [duplicate]
I'm kinda new to OpenGL, I am currently trying to make a class which can handle drawing vertices into the screen and it doesn't seem to work, it doesn't draw anything. I know that this problem has ...
0 votes
2 answers
222 views
Can you explain this line of linear search algorithm? [duplicate]
So what's this line means? int n = sizeof(arr) / sizeof(arr[0]) Why are we dividing arr with arr[0] and whats the use of n here? #include <iostream> using namespace std; int search(int arr[], ...
-2 votes
2 answers
438 views
Why C compiler says *** stack smashing detected ***: terminated [duplicate]
What is problem with my code, that it shows "stack smashing detected" Problem Statement: Given an array, we have to find the smallest element in the array. #include<stdio.h> int main(){...
0 votes
3 answers
173 views
How to get number of items in array of floats in C? [duplicate]
I'm trying to get the number of floats in the following array: float coins[] = {0.25, 0.10, 0.05}; printf("%i", sizeof(coins)); I get 12. I am trying to get 3. What am I missing here?
0 votes
2 answers
89 views
Pass array in method and get it's size [duplicate]
I need to pass an array inside a routine and then to read its size. typedef struct { unsigned char Name[20]; }Sensors_; extern volatile Sensors_ Sensor; then inside source file I'm using this ...
1 vote
5 answers
100 views
Finding length of int array in c++, how does it work? [duplicate]
Someone gave this code as a method to find the length of an array called a: std::cout << "Length of array = " << (sizeof(a)/sizeof(*a)) << std::endl; The only thing I don't ...
0 votes
1 answer
89 views
Unexpected behavior in array input [duplicate]
This function is supposed to read and expand my array (stringa) until the user hits enter, then expands also reverse to the same size of stringa. But after 3 letters the program just stops void ...