39 questions
41 votes
5 answers
7k views
Why is the 'auto' keyword useful for compiler writers in C?
I'm currently reading "Expert C Programming - Deep C Secrets", and just came across this: The storage class specifier auto is never needed. It is mostly meaningful to a compiler-writer ...
0 votes
1 answer
68 views
Pointer don't lets auto variable to get deleted after the function call [duplicate]
When I use a pointer instead of referencing operator in a function pointer do not allow auto variable to get deleted after function call. I got Segmentation fault (core dumped) from this code because ...
1 vote
1 answer
132 views
C API allowing for both automatic and allocated storage
I'm writing an API that has structs such as struct datast{ int a; int *items; size_t numitems; }; I'm providing functions which free the contents of such structs (in a similar fashion to what C++ ...
0 votes
2 answers
363 views
Do you have to deallocate a const int if you declared it inside a function?
void func() { const int intAge = 24; } What happens with intAge after you run func()? Do you have to deallocate it, or does the C++ compiler do this?
0 votes
3 answers
260 views
Absolute worst case stack size based on automatic varaibles
In a C99 program, under the (theoretical) assumption that I'm not using variable-length arrays, and each of my automatic variables can only exist once at a time in the whole stack (by forbidding ...
2 votes
3 answers
248 views
stack space for a vector that its size is given at runtime? (C code)
Supose this C code: int main(){ int n; scanf("%d\n", &n); int a[n]; int i; for (i = 0; i<n; i++){ a[i] = 1; } } We have a vector which is in ...
0 votes
1 answer
147 views
Automatically calculating percentage and store into variables
I am currently on a demographic project. I have data from 3 different countries and their birth statistics in each month. My question: I want to calculate the percentage people born in each month and ...
44 votes
3 answers
3k views
std::vector (ab)uses automatic storage
Consider the following snippet: #include <array> int main() { using huge_type = std::array<char, 20*1024*1024>; huge_type t; } Obviously it would crash on most of platforms, because ...
0 votes
2 answers
127 views
auto variables with the same name in different C blocks: memory allocation
Assume I have a structure like this in a C program: if (res == NULL) { int i = 1; ... } else { int i = 2; ... } Will I save some amount of memory if I instead write int i; if (res ==...
0 votes
0 answers
123 views
Extract email address from a file before mapping in Talend
I have a folder with 5 files. One of the files has an email address. I want to extract the email address from the file first, map it to a database, and then store it somewhere as a variable so that it ...
0 votes
1 answer
58 views
Save Debian automaticaly
I have a Debian server and I wish to "save" some files automatically and send them automatically to a googledrive. this automatic task must be done regularly (every week, for example)
5 votes
2 answers
1k views
Automatic storage duration struct initialization
Some of this may be a duplicate, but I am sorry for that. Let's say I have this struct: struct foo { int a; int b; int c; }; 1. If struct foo type object is declared in the way that it ...
2 votes
2 answers
1k views
batch or vb script to read URL from excel file and download URL attached file to specified location or directory
I am looking for a VB script or batch file to read & Execute multiple URLs from an CSV file containing the URL Data in column B & The mentioned URL directly contains on the downloadable file ...
1 vote
2 answers
104 views
accessing variable length array after its memory should have been deallocated
I'm currently studying variable length array and automatic storage. I have the following code that allocate memory for an variable length array myArray inside function vla, and return a pointer to ...
3 votes
3 answers
119 views
structure on the stack - fields initialized? [duplicate]
Consider the following code: void func() { int p; ... if (p > MAX) { struct my_struct s; ... /* here we access the contents 's' as '&s' */ } } In this snippet ...