Skip to main content
Filter by
Sorted by
Tagged with
4 votes
3 answers
227 views

In the C17's final draft N2176 document, the 7th paragraph of 6.2.4 section says For such an object that does have a variable length array type, its lifetime extends from the declaration of the ...
Cinverse's user avatar
  • 333
0 votes
2 answers
76 views

When compiling my program, I get the following error: No matching function for call to 'fillWithRandomNum' Candidate function not viable: no known conversion from 'double[10][Globals::MAX_COL]' to '...
ImDarkk's user avatar
  • 257
20 votes
6 answers
2k views

In C, you can do this: int arr[i]; From what I understand, this is called a VLA—variable length array—which is an array whose size is not known at compile time, which in most implementations is ...
דניאל פ.ח.'s user avatar
2 votes
1 answer
106 views

Issue: definition of variable length array (VLA) / known constant size seems to be recursive. C11, 6.2.5 Types, 23 (emphases added): A type has known constant size if the type is not incomplete and ...
pmor's user avatar
  • 6,757
1 vote
1 answer
102 views

I am wondering how difficult it would be to add rudimentary support for something like sizeof T[n] (which to my knowledge is an explicit C construct for a variable length array), to be used in a ...
invertedPanda's user avatar
4 votes
1 answer
141 views

@Lundin shows how to check if a passed expression is an array at compile-time here: Lvalue conversion of _Generic controlling expression involving array clang warning wrong?: #define IS_ARRAY(T) ...
Madagascar's user avatar
  • 7,440
6 votes
2 answers
141 views

Context The standard says (C17, 6.5.3.4 ¶2): The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined from ...
Lover of Structure's user avatar
0 votes
2 answers
127 views

#include<stdio.h> int main(){ int n; printf("Enter the number:"); scanf("%d",&n); int array[n]; for (int i=0;i<=n;i++){ printf("%...
Shuvarthi Dey's user avatar
-1 votes
1 answer
79 views

I'm trying to understand how sizeof() works, so I made 2 arrays, and see what is assembled, I've not used -O3 option because I thought the code to be clearer and the code is not deleted by ...
sefiroths's user avatar
  • 1,563
0 votes
1 answer
256 views

Here I have two data files with model parameters and RMSEs computed for them. I would like to get those RMSEs plotted for each model separately with the model also displayed on it. Please help. Data ...
user86927's user avatar
30 votes
2 answers
3k views

I know that the restrict qualifier in C specifies that the memory region pointed by two pointers should not overlap. It was my understanding that the Linux (not SUS) prototype for memcpy looks like - ...
tinkerbeast's user avatar
  • 2,107
0 votes
4 answers
124 views

Hello I am new to coding and was just wondering why the below code: #include <stdio.h> int main() { for(int i = 0; 1 ; i++) { char x; char z[1+i]; x=getchar(); if (x == '\n'){ ...
soda2718's user avatar
0 votes
1 answer
103 views

#include <iostream> #include <algorithm> #include <bits/stdc++.h> template<typename T, size_t Size> std::istream& operator>>(std::istream& in, T (&arr)[Size]) ...
mayank garg's user avatar
1 vote
2 answers
180 views

I have the following task: Create a 2d array A[M][N], where M and N are inputted by the user as well the elements in each row and column. There must also be two functions: 1)The first one needs to ...
Rostislav Yanev's user avatar
-2 votes
1 answer
90 views

Say I have a struct struct GRAPH { NODE* nodes[]; } With a dynamic size for nodes[]. I also have struct NODE { char filename[40]; struct NODE* links[]; } I will know how many links and nodes I ...
04Khey's user avatar
  • 3
3 votes
3 answers
196 views

I am working on a piece of legacy code (no tests). I stumbled upon a section hidden inside several macros. It generates a warning if compiled with GCC's -Wvla. The code in question is equivalent to ...
Grigory Rechistov's user avatar
2 votes
1 answer
87 views

I am reading C The Complete Reference 4th edition by Herbert Schildt. In Chapter 4 - Arrays and Strings, it mentions "One major reason for the addition of variable-length arrays to C99 is to ...
Saad's user avatar
  • 107
0 votes
3 answers
1k views

So would like to create an 2D array of characters for testing purposes. Here is my code. const int rows = 4; const int columns = 6; //char field[rows][columns]; //fill_field(rows,...
tomastrue's user avatar
-1 votes
2 answers
108 views

I have 2 arrays: int element[3] = {0, 1, 2}; int quantity[3] = {2, 3, 4}; Now I want a result array that will have two zeros, three ones and four twos. int result[2+3+4] = {0, 0, 1, 1, 1, 2, 2, 2, 2}; ...
Aaban Saad's user avatar
0 votes
1 answer
366 views

I want to convert a float vector to a float array in C++ 20. I searched online and found this solution: #include <iostream> #include <algorithm> #include <vector> int main() { ...
Pepis's user avatar
  • 9
-2 votes
2 answers
81 views

I'm just taking input for two arrays and manipulating the information. When I take input for both arrays it puts the information from the second into both arrays. In the code below I haven even ...
Molly Dempsey's user avatar
0 votes
2 answers
86 views

I got this question asked by one of my peer, as i don't know "C" that much, but still being a beginner i tried solving it, this is the approach i used, but it is not giving the expected ...
Karishma Singh's user avatar
0 votes
3 answers
1k views

I used C in Visual Studio to make a code for a user to input size of array. The code does not work in Visual Studio and gives errors. But on a site like replit it works. I don't understand what to do ...
artur anikin's user avatar
1 vote
3 answers
1k views

I am very new to C but I am having trouble on what seems a very trivial problem. All I am trying to do is create a n sized array, such that at the time of running I don't know its size and can't ...
Harry Spratt's user avatar
0 votes
1 answer
160 views

The source code as follows: using namespace std; int main() { int m = 4; int arr[m] = {1, 2, 3, 4}; printf("%d\n", arr[2]); return 0; } When I compile with ...
YoLo22's user avatar
  • 1

1
2 3 4 5
9