question stringlengths 25 894 | answer stringlengths 4 863 |
|---|---|
As precedence of && is more (is this the suitable adj.?) than precedence of ||, I wrote something like this:
```
if (a || b && c ){ ....
```
I guess the program will first findb && c, let's call itd, and then finda || d, right?
I want the the program to check "a" statement first, and then if it is wrong; check b a... |
Logical expressions in C are subject toshort-circuit evaluation. Now, as you noted,
```
a || b && c
```
is the same as
```
a || (b && c)
```
because of precedence.
Butais evaluated first, because evaluation order is left-to-right. Because of short-circuit evaluation, only ifais false does the program then go on t... |
Porting a C application from AIX to Linux - does anyone know if there's an equivalent of the mbsinvalid() function on Linux?
From the AIX pages:
"The mbsinvalid subroutine examines the string pointed to by the S parameter to determine the validity of characters. The LC_CTYPE category affects the behavior of the mbsi... |
Usembstowcswith NULL destination pointer:
If dest is NULL, n is ignored, and the conversion proceeds as above, except that the converted wide characters are not written out to memory, and that no length limit exists.....An invalid multibyte sequence has been encountered. In this case (size_t) -1 is returned.
(fro... |
In C, I can define a static variable in a function like this
```
int func() {
static int var=0
.....
}
```
Is there something equivalent to that in shell bash linux?
Is it possible to define a local variable of the bash shell function as static?
|
Withbashyou cannot really get that (I imagine you want some variable shared between several instances of your shell...). However, if you switch to thefishshell (usechshto change your login shell), you get so calleduniversalvariables which kind-of fits the bill. See alsothis answerto a related question.
BTW, you shoul... |
This question already has answers here:Ternary operator (?:) in Bash(23 answers)Closed9 years ago.
in C I can assign a value in this way:
```
val = (cond)? val_true : val_false;
```
and it's equivalent to
```
if (cond)
val = val_true;
else
val = val_false;
```
Are there an equivalent ofval=(cond)? val_tr... |
Suppose you want it to be somewhat like this:
```
true=1
[ $true ] && p=1 || p=0
```
All you have to do is keep whatever condition you want within those brackets.
If it’s valid, then the branch after the AND is followed, otherwise that after the OR is followed.
This is equivalent to this:
```
if [ $true ]; then p... |
I have tried to replace sleep() by SIGALRM.
```
#include <signal.h>
#include <unistd.h>
void sig_alrm( int signo )
{
return; /* return to wake up pause */
}
unsigned int sleep1( unsigned int nsecs )
{
if( signal( SIGALRM, sig_alrm ) == SIG_ERR )
return (nsecs);
alarm( nsecs ); /* starts timer *... |
The real implementation has to handle more conditions:
HandleEINTR.Handle thread cancellation.
Seeglibc implementatiop of sleep().
|
The code snippet below gives the output 11 11 undefined value. But why am I getting the undefined value when the same statement is executed second time ? Is that anything to do with the scope of the function?
```
void foo(int **const p)
{
int j = 11;
*p = &j;
printf("%d ", ... |
Whenfoo()exits,*ppoints to a variable that is no longer in existence. Therefore you are invoking undefined behaviour.
|
I want to add transparent button in my application and i am using gtk. How to do it?
I am usinggtk_color_button_set_alpha():
```
gtk_color_button_set_alpha(GtkColorButton *button, guint16 100);
```
But it is giving error as
error: expected expression before ‘GtkColorButton’
error: too few arguments to function ‘g... |
With a fairly recent GTK+ (3.8) this should be quite easy: Seeopacity propertyandgtk_widget_set_opacity(). Note that this depends on display manager features and you cannot rely on the opacity working everywhere. You can check if it works though:gtk_widget_is_composited()should tell you that.
|
Is
```
pointer = (int*)realloc(0, sizeof(int))
```
a valid expression?
I feel that since the first argument toreallocis a pointer and here it is 0(memory address reserved for the OS), this statement should not be a valid one. Can someone comment on the validity of the statement?
|
It is valid statement.
§7.22.3.5 from the C standard:
void *realloc(void *ptr, size_t size);Ifptris a null pointer, the realloc function behaves like the malloc function for the
specified size. Otherwise, if ptr does not match a pointer earlier returned by a memory
management function, or if the space has been deall... |
sorry for this newbie question but I don't find any good resource on web to explain what this means:
```
struct {
struct spinlock lock;
struct proc proc[NPROC]; //NPROC = 64
} ptable;
```
I see the resources over the web and find these types of define a struct:
```
//first method
struct Foo { ... };
//second m... |
```
struct foo { ... };
```
The struct tag (foohere) is optional. If it's omitted like in your example, you can use the variableptablewhich is of this type, but you can't define other variables of this type later.
|
Closed. This question needsdetails or clarity. It is not currently accepting answers.Want to improve this question?Add details and clarify the problem byediting this post.Closed9 years ago.Improve this question
How to find the PID of a C code which is being executed So that I can find its stack and heap memory usage?... |
Why not the getpid() method defined in unistd.h?
```
#include <unistd.h>
int main(){
int pid = getpid();
int parentsPID = getppid();
return 0;
}
```
|
I've seen a bunch of answers on how to convert a char array to a TCHAR array in C++, but none for pure C.
Here's what I've tried:
```
const TCHAR* ptr = NULL;
TCHAR newPath[100];
ptr = _tcsrchr(dllPath, _T('.'));
_tcsncpy(newPath, dllPath, ptr - dllPath + 1);
newPath[ptr - dllPath + 1] = NULL;
```
Crashes. Here's a... |
Try this:
```
TCHAR *tstrTo;
int tstrLen;
#ifdef UNICODE
tstrLen = MultiByteToWideChar(CP_UTF8, 0, dllPath, strlen(dllPath), NULL, 0);
tstrTo = (TCHAR*) malloc(tstrLen * sizeof(TCHAR));
MultiByteToWideChar(CP_UTF8, 0, dllPath, strlen(dllPath), tstrTo, tstrLen);
#else
tstrTo = strdup(dllPath);
tstrLen = strlen(tstrTo)... |
This question already has answers here:Portable way to pass file descriptor between different processes(2 answers)Closed9 years ago.
The answer tothis questionshows how to share a file descriptor between two processes. I am unclear on whether this is possible with any process or only related processes. For example, i... |
Yes, you can pass a file descriptor to any other process. The only requirement is that you open a Unix domain socket to communicate between the two processes.
|
I have that simple hello world program.
First row it says#include <stdio.h>.
I googled it and it tells basically the preprocessor to define the functions for input/output.
First question:I read that the actually code of the function first compiled to an object file. So if I say#include <foo.bar>itautomaticallylinkes... |
printf()is located in standard C library and linker links standard library to your program.
So any standard functions will not be any linking problems.
If you compile the program without#include<stdio.h>usinggccyou will get the warning.
|
This question already has answers here:What happens when float pointer is typecasted to char pointer?(6 answers)Closed9 years ago.
The output of the below code is0.0000. What is happening in the code and why the output is0.0000or to ask preciselywhat happens when we type cast theint*tofloat*and print the de-reference... |
Did you mean?
```
printf("%f\n", (float)*p);
```
Edit: After you clarified your question.
There will be undefined behaviour if you try to convertInt*tofloat*. Pointer is a address, and int float are stored in memory in different format. so you can not cast it.
|
Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.Questions asking for code mustdemonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and theexpectedresults. See also:Stack Overflow question checklistClosed9 ... |
If you mean something like this:
```
printf("Hello : %d\n", 7);
```
then yes, it's fine.
|
I use Qt Creator all the time to write C, C++, Qt programs.
Recently I came across an issue while debugging C++ code.
Generally Qt Creator's debugging view allows to see the contents of std::vector, but it doesn't allow for C style arrays.
Here's what it looks like
In the imagesameis a vector of bool, I can see t... |
In expression evaluator try below
*notSame@10
infact you can writenas below
```
*notSame@n
```
|
I have two simple source files:
main.c
```
void main(){
print_hello();
}
```
hello.c
```
#include<stdio.h>
void print_hello(){
printf("Hellow world \n");
}
```
After compiling with bash command:
```
gcc -c hello.c
gcc -c main.c
```
it's ok. Why when we typegcc -o hello.o main.oerror is occuring:
```
mai... |
gcc -o hello.o main.omeans: "Output executable filehello.oby linking the subsequent files (main.o)".
gcc -o hello hello.o main.omeans: "Output executable filehelloby linking the subsequent files (hello.oandmain.o)".
|
I can change the size of console window like this:
```
mode con cols=64 lines=32
```
Though there are manyapi functions for console subsystem, I could not find any function for setting the size of console window.
Is it able to set the size of console window without calling
```
system ("mode con cols=64 lines=32")... |
UseSetConsoleWindowInfo
```
BOOL WINAPI SetConsoleWindowInfo(
_In_ HANDLE hConsoleOutput,
_In_ BOOL bAbsolute,
_In_ const SMALL_RECT *lpConsoleWindow
);
```
hConsoleOutputis a screen buffer handle returned byCreateConsoleScreenBuffer.
|
I have been trying to try to figure out if I could usesscanf(3)to get a users input to do a command. In this case if they enter "exit", I want the program to terminate. I tried this...
```
char exitNow[100];
if(sscanf("exit", "%s", exitNow))
{
exit(0);
}
```
For some reason this will not termina... |
I think you are using the wrong function for what you are trying to do. Assuming exitNow is filed by input somewhere else, you probably want:
```
if (!strcmp(exitNow, "exit"))
exit(0);
```
|
Closed. This question needsdetails or clarity. It is not currently accepting answers.Want to improve this question?Add details and clarify the problem byediting this post.Closed9 years ago.Improve this question
How do I export a command-line tool (in C) project from Xcode?
(Xcode 5 on Mac OS X)
|
Just right click on the executable in the Xcode project and select "Show In Finder" to navigate to the compiled program. Not sure what else you're interested in.
|
```
#include <stdio.h>
main()
{
printf(" %d\n",'-'-'-'+'/'/'/');
}
```
its giving output as1.
I have also tried different combinations but cant make out
the output ?
|
The character constant'-'has ASCII value 45, while'/'has ASCII value 47. So assuming you're running on a system that uses ASCII or UTF-8 character encodings, the expression evaluates to
```
'-' - '-' + '/' / '/' == 45 - 45 + 47 / 47 == 0 + 1 == 1
```
Hence the output "1".
EDIT
KerrekSB rightly points out that th... |
I'm programming in C. I'd like to search a string inside of a string.
Are there any built-in function that does that in string.h ? Or do you know how to create one ?
|
Are there any built-in function that does that in string.h ?
Yes. Take a look atstrstr(), which is part of the standard library and declared in string.h.
|
What's the most efficient way to calculate the amount of padding for 8-bit data that needs to be a multiple of 32-bit in C?
At the moment I do it like this:
```
pad = (4-size%4)%4;
```
|
As long as the optimizing compiler uses bitmasking for the% 4instead of division, I think your code is probably pretty good. This might be a slight improvement:
```
// only the last 2 bits (hence & 3) matter
pad = (4 - (size & 3)) & 3;
```
But again, the optimizing compiler is probably smart enough to be reducing yo... |
Hi I am tring to use TCP_QUICKACK under fedora core 17
but like below
```
setsockopt(sockfd, IPPROTO_TCP, TCP_QUICKACK, (int[]){1}, sizeof(int))
```
but when I try to compile it I get
error: ‘TCP_QUICKACK’ undeclared
what I need to do
pls help
|
I don't have a copy of Fedora handy, but under Ubuntu 12.04, TCP_QUICKACK is defined in netinet/tcp.h (and in linux/tcp.h).
You can probably find the correct header by using the following shell command:
```
find /usr/include -name "*.h" | xargs grep TCP_QUIKACK
```
(If you system doesn't use /usr/include, substitut... |
I have a string"h264:640x480:4:30000". I used sscanf function as follow.
```
char res[16] = { 0 };
int quality = 0;
int fps = 0;
sscanf(temp1, "h264:%s:%d:%d", res, &quality, &fps);
```
when this function is executed. I was expecting "640x480" in "res", "4" in "quality" and "3000" in "fps". but it copied whole strin... |
Use the followingsscanf()string format
```
sscanf(temp1, "h264:%[^:]:%d:%d", res, &quality, &fps);
```
%swill catch all charachters in the string till it find a white space or reach the end of the string. so%sis not a good choice.
%[^:]will catch all charachters in the string till it find the':'charachter or reach ... |
I have set the "Architectures" setting in Xcode to armv7, armv7s.
What happens when I run my app on an arm64 device like the iPhone5s.
Will the size oflongbe 64bit or 32bit ?
|
Thecompilercreates 32-bit or 64-bit code, depending on the selected architecture.
Therefore, if the app is compiled for a 32-bit architecture (like armv7, armv7s),
the size oflongis 32-bit, regardless of the actual device that the code is
running on.
|
This question already has answers here:Does gcc automatically initialize static variables to zero?(2 answers)Closed9 years ago.
for example
```
static char all_data;
```
without initializing value to it. what is the default value? Or is it a Undefined Behavior?
I tried on my gcc-4.6 the answer is 0.
Thanks.
|
Per C99:
```
If an object that has static storage duration is not initialized explicitly,
then:
— if it has pointer type, it is initialized to a null pointer;
— if it has arithmetic type, it is initialized to (positive or unsigned) zero;
— if it is an aggregate, every member is initialized (recursively) according to ... |
I am new in Matlab programming but have to convert a C program in Matlab. There are few parts which is making me confused. I am putting here the parts for both C and Matlab and looking for your suggestion for improvement of the code because the full code is not giving right output:
C Code:
```
j = 0;
for (i=0;i<256... |
Since you're using the expressionsc(i0+1)to calculate the reminder you should start theforloop from 0.
```
le = length(key);
sc = 0:255;
output = 0;
for i0 = 0:255
output=rem((output+sc(i0+1)+key(rem(i0,le)+1)),256);
end
```
|
Closed. This question needsdetails or clarity. It is not currently accepting answers.Want to improve this question?Add details and clarify the problem byediting this post.Closed9 years ago.Improve this question
In e2fsprog code base, there is one line such as:
```
#define NO_BLK ((blk64_t) -1)
```
and
```
typedef ... |
That is not what has happened here.
The(blk64_t)casts (converts) the value at it's right to the typeblk64_t.
Here the value is -1. In 64-bit two's complement notation, signed integer-1and unsigned integer2^64-1has the same representation. 1111...111 (64 ones)
|
I am compiling the code below as
```
$ gcc -Wall -ftrapv test.c
```
However running the generated executable always prints-2147483648 which is not what I expected. I am running gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5).
```
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <limits.h>
4 #include <s... |
It looks like-ftrapvsupport in GCC is somewhat broken, they have anopen bug, Bug-35412in their Bugzilla from 2008 it seems in order to cover it.
|
When trying to run this:
```
int main()
{
return 0;
}
```
I get the
```
Launch failed. No binary found.
```
error. Why? I have the correct path set (C:\cygwin64\bin). Also, I have theCygwinPE set too. Finally, I installed thedevelpackage. Any help?
Also getting the 3 errors of:
```
G++, gcc and make not found in... |
Try to installMinGWinstead, it works perfectly with eclipse: just make sure to set the install directory toC:\MinGW(the directory name is case-sensitive).
Then you have to set a compiler for your projects: Go to Window -> Prefrences then
Then create a new project and set the compiler for it:
Before run your pro... |
Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.Questions asking for code mustdemonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and theexpectedresults. See also:Stack Overflow question checklistClosed9 ... |
You're mixing up things. GLEW is completely unrelated to window creation. It's there to load extension and modern OpenGL functions.
GLUT is not the only OpenGL windowing framework around. If you want to implement your own event loop have a look at GLFW, or SDL-2 or SFML. Other than that you've got a lot of work ahead... |
```
#include <stdio.h>
main()
{
printf(" %d\n",'-'-'-'+'/'/'/');
}
```
its giving output as1.
I have also tried different combinations but cant make out
the output ?
|
The character constant'-'has ASCII value 45, while'/'has ASCII value 47. So assuming you're running on a system that uses ASCII or UTF-8 character encodings, the expression evaluates to
```
'-' - '-' + '/' / '/' == 45 - 45 + 47 / 47 == 0 + 1 == 1
```
Hence the output "1".
EDIT
KerrekSB rightly points out that th... |
I'm programming in C. I'd like to search a string inside of a string.
Are there any built-in function that does that in string.h ? Or do you know how to create one ?
|
Are there any built-in function that does that in string.h ?
Yes. Take a look atstrstr(), which is part of the standard library and declared in string.h.
|
What's the most efficient way to calculate the amount of padding for 8-bit data that needs to be a multiple of 32-bit in C?
At the moment I do it like this:
```
pad = (4-size%4)%4;
```
|
As long as the optimizing compiler uses bitmasking for the% 4instead of division, I think your code is probably pretty good. This might be a slight improvement:
```
// only the last 2 bits (hence & 3) matter
pad = (4 - (size & 3)) & 3;
```
But again, the optimizing compiler is probably smart enough to be reducing yo... |
Hi I am tring to use TCP_QUICKACK under fedora core 17
but like below
```
setsockopt(sockfd, IPPROTO_TCP, TCP_QUICKACK, (int[]){1}, sizeof(int))
```
but when I try to compile it I get
error: ‘TCP_QUICKACK’ undeclared
what I need to do
pls help
|
I don't have a copy of Fedora handy, but under Ubuntu 12.04, TCP_QUICKACK is defined in netinet/tcp.h (and in linux/tcp.h).
You can probably find the correct header by using the following shell command:
```
find /usr/include -name "*.h" | xargs grep TCP_QUIKACK
```
(If you system doesn't use /usr/include, substitut... |
I have a string"h264:640x480:4:30000". I used sscanf function as follow.
```
char res[16] = { 0 };
int quality = 0;
int fps = 0;
sscanf(temp1, "h264:%s:%d:%d", res, &quality, &fps);
```
when this function is executed. I was expecting "640x480" in "res", "4" in "quality" and "3000" in "fps". but it copied whole strin... |
Use the followingsscanf()string format
```
sscanf(temp1, "h264:%[^:]:%d:%d", res, &quality, &fps);
```
%swill catch all charachters in the string till it find a white space or reach the end of the string. so%sis not a good choice.
%[^:]will catch all charachters in the string till it find the':'charachter or reach ... |
I have set the "Architectures" setting in Xcode to armv7, armv7s.
What happens when I run my app on an arm64 device like the iPhone5s.
Will the size oflongbe 64bit or 32bit ?
|
Thecompilercreates 32-bit or 64-bit code, depending on the selected architecture.
Therefore, if the app is compiled for a 32-bit architecture (like armv7, armv7s),
the size oflongis 32-bit, regardless of the actual device that the code is
running on.
|
I was trying to declare a function pointer that points to any function that returns the same type. I omitted the arguments types in the pointer declaration to see what error will be generated. But the program was compiled successfully and executed without any issue.
Is this a correct declaration? Shouldn't we specify... |
Empty parentheses within a type name means unspecified arguments. Note that this is an obsolescent feature.
C11(ISO/IEC 9899:201x) §6.11.6 Function declaratorsThe use of function declarators with empty parentheses (not prototype-format parameter
type declarators) is an obsolescent feature.
|
I'm reading Linux kernel 3.12.When I read about i2c_put_adapter in driver/i2c/i2c-core.c,I'm confused.Function "i2c_put_adapter" calls module_put in kernel/module.c ,then module_put called "trace_module_put".But after search all the source code,I cannot find this function and "trace_module_get" ether. While I think th... |
trace_* are macros used by tracepoint which is one static trace utility. you can explore trace point starting from "include/trace/events/module.h" as you are looking for how trace_module_put is 'implemented'
Documentation/trace/tracepoints.txt is the kernel doc for tracepoints.
|
What is the best way to zip two (or more) numbers' bit representations together in C/C++/Obj-C?
I have num one to three. Their binary representations are [abc, ABC, xyz]. I would like to produce a num with binary [aAxbBycCz]. I'm mainly working with numbers that are over 21 bits.
(Ignoring the limit on integers, end... |
A solution that should work for any number of bits:
```
const unsigned int BITS = 21;
unsigned int zipper(unsigned a0, unsigned a1, unsigned a2)
{
unsigned int result = 0;
for (unsigned int mask = 1<<BITS; mask != 0; mask >>= 1)
{
result |= a0 & mask;
result <<= 1;
result |= a1 & m... |
Can I use Visual Studio to learn C programming? In the new project menu I can choose between Visual Basic, Visual C#, Visual C++, Visual F# and others but I don't see "C" or "Visual C".
|
Short answer: Yes, you need to rename .cpp files to c, so you can write C:https://msdn.microsoft.com/en-us/library/bb384838.aspx?f=255&MSPPError=-2147217396
From the link above:
By default, the Visual C++ compiler treats all files that end in .c as C source code, and all files that end in .cpp as C++ source code. To... |
I read a lot of stuff about strtok(char* s1, char* s2) and its implementation. However, I still can not understand what makes it a dangerous function to use in multi-threaded program. Can somebody please give me an example of a multi-threaded program and explain the issue there? Please not that I am looking for an exa... |
In the first call to strtok, you supply the string and the delimiters. In subsequent calls, the first parameter is NULL, and you just supply the delimiters. strtok remembers the string that you passed in.
In a multithreaded environment, this is dangerous because many threads may be calling strtok with different str... |
The following code is used on an embedded target to save a struct (of type Config) to eeprom by accessing the individual bytes in the struct's location in memory and writing them to EEPROM. What is the C equivalent of this type of pointer usage?
```
int EepromSaveBlock(int ee, const Config& value)
{
const byte* p... |
```
int EepromSaveBlock(int ee, const Config* value)
{
const byte* p = (const byte*)value;
unsigned int i;
for (i = 0; i < sizeof(*value); i++)
{
EEPROM.write(ee++, *p++);
}
return (int) i;
}
```
|
I have a question regarding python memory management. I have the following code
```
def operation(data):
#some manipulations on data
result=something.do(data)
#some manipulations on result
return result
```
Now I am calling this functionoperationmany times (probably like more than 200 times). Does py... |
The whole point of high-level languages like Python is that they free you from having to worry about memory management. If exact control over memory allocation is important to you, you should write C. If not, you can write Python.
As most Python programmers will tell you from their experience, manual memory managemen... |
I want to write a code for making square-root not using pow().here is what i have tried:
```
#include <stdio.h>
#include <stdlib.h>
int main(){
int a,I,sum=0,cnt=0;
printf("enter number");
scanf("%d",&a);
for(I=1;sum<a;I+=2){
sum+=I;
cnt++;
}
printf("answer is:%d",cnt);
re... |
```
for(I=1;;I+=2){
sum+=I;
if(sum>a)
break;
cnt++;
}
```
|
Closed. This question needs to be morefocused. It is not currently accepting answers.Want to improve this question?Update the question so it focuses on one problem only byediting this post.Closed9 years ago.Improve this question
I don't seem to understand the need of *.lib files. Let's say I have 3 *.c files:
```
mo... |
*.lib files are for other programmers who want to use your functions in their own programs.
*.exe files are for end users who just want to run your program.
|
i need to use the modulo operation inside a kernel and it is slowing things down. It is impossible for me to remove it. Basically i have a%b where b is not a power of 2. Is there any way to avoid using it?
|
Can you prefetch the answers and use a lookup table?
Instead of
```
c = a%b;
```
you could then try
```
c = table[a][b];
```
Some considerations to signature and tablesize have to be made.
Depending on the overall usecase you could move this table to a higher level and remove more that just this single computation... |
Whenever I try running this, it returns the wrong solution, for example:A: 303B: 405C: 50
Real solution: −0.13762776465722773My solution : -110079.531250
```
#include <stdio.h>
#include <math.h>
int main(){
float a;
float b;
float c;
float solution;
float d;
printf("A: ");
scanf("%f", &a)... |
You forgot BODMAS. Replace(-b - sqrt(d))/ 2*aby(-b - sqrt(d))/ (2*a)
|
stb_image appears to have support for plug-in SIMD implementation(s) of the idct and ycbcr->rgb conversion operations, which take majority of time when loading jpeg files. Looking at the code behind STBI_SIMD it's pretty clear this code has actually been used somewhere.
However, either the implementations have been p... |
I remember seeing your question on Twitter, where today coincidently someone mentionedlibjpeg-turbolicensed under the BSD license. Hope that helps.
|
Closed. This question isopinion-based. It is not currently accepting answers.Want to improve this question?Update the question so it can be answered with facts and citations byediting this post.Closed9 years ago.Improve this question
which of these codes is better?
```
do {
fread( ... );
if(!feof(fp)) { ... }
}
wh... |
Neither. You are better off making the eof test part of the loop condition (at the top).
You can do this:
```
while (!feof(fp)) {
fread(...);
}
```
Sincefreadreturns the number of objects read, youcouldshould also do it this way:
```
while (fread(...) != 0) {
}
```
|
The code below works like expected if the user enters only integers.
```
#include <stdio.h>
int main()
{
int input1, input2;
int error;
error = scanf("%d", &input1);
if( !error)
printf("Error: Your input was wrong\n");
else
printf("Your input was: %d\n", input1);
error = sca... |
```
if(!error){
printf("Error: Your input was wrong\n");
scanf("%*[^\n]");
} else
printf("Your input was: %d\n", input1);
```
|
I see this interesting questionhereasking for the possibility of a program withoutmain(). There, I saweongiving one answer as follows, which works well in C/C++.
```
#include<stdio.h>
#define decode(s,t,u,m,p,e,d) m##s##u##t
#define begin decode(a,n,i,m,a,t,e)
int begin()
{
printf(" hello ");
}
```
Can someone ex... |
Have a close look at the macro: it just spliced togethermainfrom the characters inanimateand gets them replaced forbegin().
|
I'm trying to useatoi()but I need the0in the front, but the function ignores it
```
sprintf(str, "%d%d%d%d",comp[cont][0],comp[cont][1],comp[cont][2],comp[cont][3]);
conv=atoi(str);
printf("%d \n",conv);
```
When I print str:0100And conv:100Is there any way to show the0?
|
It's because integers simply doesn'thavezeros in front of them.
You need to print it with that:
```
printf("%04d \n",conv);
```
You might find e.g.thisprintfreferenceuseful.
|
I've a
```
struct addrinfo *s;
```
and i want to see the fields
```
struct sockaddr *ai_addr;
```
inside my struct (s) when I'm in debug mode. I use code-blocks ide for testing my programs, and in the Debug Watches window I have set the correct watch
```
*s->ai_addr
```
but it print only the memory address. Then... |
Because you trying to printai_addrwhich is pointer aka address
|
What is the best way to zip two (or more) numbers' bit representations together in C/C++/Obj-C?
I have num one to three. Their binary representations are [abc, ABC, xyz]. I would like to produce a num with binary [aAxbBycCz]. I'm mainly working with numbers that are over 21 bits.
(Ignoring the limit on integers, end... |
A solution that should work for any number of bits:
```
const unsigned int BITS = 21;
unsigned int zipper(unsigned a0, unsigned a1, unsigned a2)
{
unsigned int result = 0;
for (unsigned int mask = 1<<BITS; mask != 0; mask >>= 1)
{
result |= a0 & mask;
result <<= 1;
result |= a1 & m... |
Can I use Visual Studio to learn C programming? In the new project menu I can choose between Visual Basic, Visual C#, Visual C++, Visual F# and others but I don't see "C" or "Visual C".
|
Short answer: Yes, you need to rename .cpp files to c, so you can write C:https://msdn.microsoft.com/en-us/library/bb384838.aspx?f=255&MSPPError=-2147217396
From the link above:
By default, the Visual C++ compiler treats all files that end in .c as C source code, and all files that end in .cpp as C++ source code. To... |
I read a lot of stuff about strtok(char* s1, char* s2) and its implementation. However, I still can not understand what makes it a dangerous function to use in multi-threaded program. Can somebody please give me an example of a multi-threaded program and explain the issue there? Please not that I am looking for an exa... |
In the first call to strtok, you supply the string and the delimiters. In subsequent calls, the first parameter is NULL, and you just supply the delimiters. strtok remembers the string that you passed in.
In a multithreaded environment, this is dangerous because many threads may be calling strtok with different str... |
The following code is used on an embedded target to save a struct (of type Config) to eeprom by accessing the individual bytes in the struct's location in memory and writing them to EEPROM. What is the C equivalent of this type of pointer usage?
```
int EepromSaveBlock(int ee, const Config& value)
{
const byte* p... |
```
int EepromSaveBlock(int ee, const Config* value)
{
const byte* p = (const byte*)value;
unsigned int i;
for (i = 0; i < sizeof(*value); i++)
{
EEPROM.write(ee++, *p++);
}
return (int) i;
}
```
|
I have a question regarding python memory management. I have the following code
```
def operation(data):
#some manipulations on data
result=something.do(data)
#some manipulations on result
return result
```
Now I am calling this functionoperationmany times (probably like more than 200 times). Does py... |
The whole point of high-level languages like Python is that they free you from having to worry about memory management. If exact control over memory allocation is important to you, you should write C. If not, you can write Python.
As most Python programmers will tell you from their experience, manual memory managemen... |
I want to write a code for making square-root not using pow().here is what i have tried:
```
#include <stdio.h>
#include <stdlib.h>
int main(){
int a,I,sum=0,cnt=0;
printf("enter number");
scanf("%d",&a);
for(I=1;sum<a;I+=2){
sum+=I;
cnt++;
}
printf("answer is:%d",cnt);
re... |
```
for(I=1;;I+=2){
sum+=I;
if(sum>a)
break;
cnt++;
}
```
|
Is it possible to put(or copy) sprintf output to pointer? How?
Like this?
```
double myNumber = 88.123;
char *pointer;
sprintf(pointer, myNumber);
```
|
If you read themanual for sprintf, you would find that the arguments for it are:
```
int sprintf(char *str, const char *format, ...);
```
Wherestris a pointer containing the address of where you want the output to be saved and the rest of the arguments being identical to printf.
In your case, you'd want:
```
doubl... |
How can i use square?
For example below calculation:
```
2^4=16
```
But when i do this the result is:6
Is there any library for this calculation without using multiplication?
```
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
int c,a=2,b=4;
c=a^b;
printf("%d",c);
return 0... |
In C,^is the XOR operator.2 XOR 4does indeed equal6.
You should include themath.hheader file:
```
#include <math.h>
double pow( double base, double exp );
...
x = pow(2, 4);
```
|
I'm trying to implement 2-3 trees and I get a segmentation fault when searching for the node to be deleted. Here's the code:
```
p = root;
while (p!=NULL || p->k1!=kkey || p->k2!=kkey)
{
if (kkey < p->k1)
p = p->st;
else if (kkey > p->k1 && kkey < p->k2)
p = p->mid;
else
p = p->... |
Yourwhilecondition looks highly suspect.
Let's saypisNULL; thewhilewill still try to dereferencep->k1and will segfault.
Did you mean to say&&("and") instead of||("or")?
|
I have defined a constant as follows
```
#define M_PI 3.14159265358979323846;
```
And I cannot use it as an argument in the pow-function
```
double d = pow(M_PI * 2, 0.5);
```
That is - the squareroot of M_PI * 2
I get a cryptic syntax-error in eclipse
What is wrong with this code? Have no problem using the cons... |
Remove the trailing semicolon from this line:
```
#define M_PI 3.14159265358979323846;
```
to have it look like this:
```
#define M_PI 3.14159265358979323846
```
Macros are expanded by the pre-processor before compilation, so the code passed to the compiler using your version would look like:
```
double d = pow(3... |
This question already has an answer here:Determining if file has been copied or not in C [closed](1 answer)Closed9 years ago.
In Windows, if you go to a file's properties it shows the last access time right under the time last modified. This changes when I copy it.
How do I view this in C?
|
You can use theGetFileTime()function to get it. ThisMSDN articlehas more details about file times.
|
Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.Questions asking for code mustdemonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and theexpectedresults. See also:Stack Overflow question checklistClosed9 ... |
use %f instead of %d in sprintf. %d is for printing integer so its truncating the digits after decimal point.
```
float val1 = 51.48
sprintf(buffer, "/xxx/xxx.php?load=%f", val1);
```
|
I am sending 2 strings to a function with pointers, and I expect one of them to change when they get back to main function. but it just returns null, as it shouldn't.
```
int main (){
...
char *str1="SOME RANDOM INPUT";
char *str2=NULL;
function1 (str1, str2);
...
}
void function1 (char mystr, char *output){
char *... |
I think you should work with pointers to pointers to get the pointer changed, like that:
```
int main (){
...
char *str1="SOME RANDOM INPUT";
char *str2=NULL;
function1 (&str1, &str2);
...
}
void function1 (char **input, char **output){
...
if (*input != NULL)
*output = *input;
return;
}
```
|
Closed.This question does not meetStack Overflow guidelines. It is not currently accepting answers.This question does not appear to be abouta specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic onanother Stack Exchange site,... |
Yes you can, for example Windows SDK comes with a Visual C++ compiler, but it doesn't contain Visual Studio, a quick search foundthis msdn page.
LE "brilliant" decision from Microsoft: it seems thatnewer Windows SDKdoesn't come with compilers, so you need to install Visual Studio to have what to use from command line... |
I've just started programming c and I'm working through The C Programming Language by Brian W.Kernighan and Dennis M.Richie.
One of the first examples is character counting and the following program is given, but when I enter a string no result it printed.
```
#include <stdio.h>
main()
{
long nc;
nc = 0;
... |
You have to finish the input. Your program will count characters untilEOFis encountered.EOF, in the keyboard, can be sent by pressingCtrl-ZthenENTERif you are in Windows, orCtrl-DthenENTERif you are in Linux/OS X.
|
I'm looking at someone else's code and trying to figure out the logic behind what they wrote. What would one use the following random number calculation for?
```
return ( ((rand() % 10000)+1) <= Rate * 100);
```
Ratehere is being used for a user-specified value representing an overall percentage of when a certain ev... |
The left part of the expression returns a random number between 1 and 10,000 (due to the+ 1; otherwise it would be between 0 and 9,999).
Ratecan then be used to determine the effective chance of the expression beingtrue. The higherRateis, the higher the chance of returningtrue.
SinceRateis multiplied with 100, you'r... |
I know about the regex implementations out there, including the POSIX version which is widely available for C. However, it is not available everywhere. And I don't need the full regex expressiveness.
So I was looking for a simple way to match a single C-string using the single wildcard '*'. E.g.
a*, b*c, *d
where '... |
You want to look intoglob(3)and possiblyfnmatch(3)instead of using POSIX regexps.
Otherwise, just escape all chars that need escaping in RE (such as.) and convert*into.*and tack on^and$as needed (and change^.*and.*$into the empty string).
|
I am looking to add multiple parts to a parameter.
Like this, I know know in VB.net i can do
```
messagebox("hello" + textbox1.text) // yields hello and whatever is in textbox1
```
but how would I do this in C?
I tried&and+but it give me errors.
i want to create 5 files, and use a for loop to create them, countin... |
In this case, you may use snprintf:
```
char buffer[FILENAME_MAX];
snprintf(buffer,FILENAME_MAX,"data%d.txt",counter+1); //You will probably start counter at 0
buffer[FILENAME_MAX-1]=0;// snprintf may skip null terminator.
FILE* ofp=fopen(buffer,"w");
//...
fclose(ofp);
```
|
I know how to count nodes on a level of a tree recursively (used tips from this answerhttps://stackoverflow.com/a/12879973/2663649), but I can't form an iterative algorithm, and not sure if I should use stack or pointer array to save previous nodes (to return to root).
|
You can turn your recursive algorithm into an iterative one.Just use a stack structure where you do the recursion.
|
I have amalloced array, and I need to pass its address to another function so that it can manipulate it. However, it looks like my C is rusty.
Here is the minimal code to reproduce the issue:
```
#include <stdio.h>
#include <stdlib.h>
void f(int **ints)
{
printf("%d\n", *ints[1]);
}
int main()
{
int *ints ... |
1) You just have the operator precedence wrong ([]for array subscripts has higher precedence than*for pointer dereference). Add an extra set of parentheses, and you should be fine:
```
printf("%d\n", (*ints)[1]);
```
2) You're allocating 3 bytes of memory instead of3 * sizeof(int)(hat tip:alk):
```
int *ints = mall... |
I have a text file in which of its line, there is two numbers. each of them are nodes of a graph. the size of the file is 1.5 gb and had has 92522018 lines. the wanted thing is the node with maximum number of edges.
i need the the array for solving this problem.
is there any way to allocate this size of array or eve... |
For C,
Usemalloc
For C++,
UseVectors
|
I wrote a simple code with dev but it does not return any thing.but with code block answer shows.what is the problem?
```
#include <stdio.h>
int main() {
int x,y,z;
scanf("%d%d",&x,&y);
while(z!=0){
z=x%y;
printf("%d",z);
}
return 0;
}
```
|
Two problems I can see:
```
1. Value to z is un-assigned. So garbage.
2. Value of z will not change, so it's infinite loop.
```
|
whatfor (i=0;1;i++)exactly does? when thefor loopwill terminate? after reaching value ofi=1? When will that happen?
(looked for this type of loop in internet and Book C(how to program, Deitel&Deitel), without any result...)
```
int i;
for (i=0;1;i++)
{
// Some code starts
// ...
//... |
Since in C anintcan be interpreted as a boolean using a zero/non-zero rule (zero means "false", anything else means "true") the loop is going to continue until abreakstatement is reached inside the loop's body.
You can rewrite the same loop as
```
for (i=0; ;i++)
```
because in the absence of a condition in the mid... |
I found it strange, that I am getting compile error when usingsizeof int, whilesizeof var(where var is a variable) works just fine.
```
int a;
a = (int) sizeof( a ); //ok
a = (int) sizeof( int ); //ok
a = (int) sizeof a; //ok
a = (int) sizeof int; //error
```
Can anyone tell me, why do I get the error?
(older mac... |
According to the C standard (cited from ISO/IEC 9899:TC3 section 6.5.3.4):
The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type.
So using a type name without parenthesis isn't legal.
Also,sizeofreturns an implementation defined value of the ty... |
The following prints the percentage of memory used.
```
printf (TEXT("There is %*ld percent of memory in use.\n"),
WIDTH, statex.dwMemoryLoad);
```
WIDTH is defined to be equal to 7.
What does TEXT mean, and where is this sort of syntax defined in printf?
|
As others already said,TEXTis probably a macro.
To see what they become, simply look at the preprocessor output. If are using gcc:
```
gcc -E file.c
```
|
```
#include <stdio.h>
void main()
{
int i = -3, j=2, k=0, m;
m= ++i|| ++j && ++k;
printf("%d%d%d%d", i, j, k, m);
}
```
If we see order of evaluation in++i|| ++j && ++k;we will come up with evaluation of++j && ++kat first it will increment value of j and k and it will evaluate as 1 af... |
||and&&are short-circuiting operators. They don't evaluate the second operand if it is not necessary to determine the output.
Here,++ievaluates to a non-zero value, which istruein a boolean context. The right-hand side is not evaluated at all.
|
I have amalloced array, and I need to pass its address to another function so that it can manipulate it. However, it looks like my C is rusty.
Here is the minimal code to reproduce the issue:
```
#include <stdio.h>
#include <stdlib.h>
void f(int **ints)
{
printf("%d\n", *ints[1]);
}
int main()
{
int *ints ... |
1) You just have the operator precedence wrong ([]for array subscripts has higher precedence than*for pointer dereference). Add an extra set of parentheses, and you should be fine:
```
printf("%d\n", (*ints)[1]);
```
2) You're allocating 3 bytes of memory instead of3 * sizeof(int)(hat tip:alk):
```
int *ints = mall... |
I have a text file in which of its line, there is two numbers. each of them are nodes of a graph. the size of the file is 1.5 gb and had has 92522018 lines. the wanted thing is the node with maximum number of edges.
i need the the array for solving this problem.
is there any way to allocate this size of array or eve... |
For C,
Usemalloc
For C++,
UseVectors
|
I wrote a simple code with dev but it does not return any thing.but with code block answer shows.what is the problem?
```
#include <stdio.h>
int main() {
int x,y,z;
scanf("%d%d",&x,&y);
while(z!=0){
z=x%y;
printf("%d",z);
}
return 0;
}
```
|
Two problems I can see:
```
1. Value to z is un-assigned. So garbage.
2. Value of z will not change, so it's infinite loop.
```
|
whatfor (i=0;1;i++)exactly does? when thefor loopwill terminate? after reaching value ofi=1? When will that happen?
(looked for this type of loop in internet and Book C(how to program, Deitel&Deitel), without any result...)
```
int i;
for (i=0;1;i++)
{
// Some code starts
// ...
//... |
Since in C anintcan be interpreted as a boolean using a zero/non-zero rule (zero means "false", anything else means "true") the loop is going to continue until abreakstatement is reached inside the loop's body.
You can rewrite the same loop as
```
for (i=0; ;i++)
```
because in the absence of a condition in the mid... |
I found it strange, that I am getting compile error when usingsizeof int, whilesizeof var(where var is a variable) works just fine.
```
int a;
a = (int) sizeof( a ); //ok
a = (int) sizeof( int ); //ok
a = (int) sizeof a; //ok
a = (int) sizeof int; //error
```
Can anyone tell me, why do I get the error?
(older mac... |
According to the C standard (cited from ISO/IEC 9899:TC3 section 6.5.3.4):
The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type.
So using a type name without parenthesis isn't legal.
Also,sizeofreturns an implementation defined value of the ty... |
The following prints the percentage of memory used.
```
printf (TEXT("There is %*ld percent of memory in use.\n"),
WIDTH, statex.dwMemoryLoad);
```
WIDTH is defined to be equal to 7.
What does TEXT mean, and where is this sort of syntax defined in printf?
|
As others already said,TEXTis probably a macro.
To see what they become, simply look at the preprocessor output. If are using gcc:
```
gcc -E file.c
```
|
```
#include <stdio.h>
void main()
{
int i = -3, j=2, k=0, m;
m= ++i|| ++j && ++k;
printf("%d%d%d%d", i, j, k, m);
}
```
If we see order of evaluation in++i|| ++j && ++k;we will come up with evaluation of++j && ++kat first it will increment value of j and k and it will evaluate as 1 af... |
||and&&are short-circuiting operators. They don't evaluate the second operand if it is not necessary to determine the output.
Here,++ievaluates to a non-zero value, which istruein a boolean context. The right-hand side is not evaluated at all.
|
whatfor (i=0;1;i++)exactly does? when thefor loopwill terminate? after reaching value ofi=1? When will that happen?
(looked for this type of loop in internet and Book C(how to program, Deitel&Deitel), without any result...)
```
int i;
for (i=0;1;i++)
{
// Some code starts
// ...
//... |
Since in C anintcan be interpreted as a boolean using a zero/non-zero rule (zero means "false", anything else means "true") the loop is going to continue until abreakstatement is reached inside the loop's body.
You can rewrite the same loop as
```
for (i=0; ;i++)
```
because in the absence of a condition in the mid... |
I found it strange, that I am getting compile error when usingsizeof int, whilesizeof var(where var is a variable) works just fine.
```
int a;
a = (int) sizeof( a ); //ok
a = (int) sizeof( int ); //ok
a = (int) sizeof a; //ok
a = (int) sizeof int; //error
```
Can anyone tell me, why do I get the error?
(older mac... |
According to the C standard (cited from ISO/IEC 9899:TC3 section 6.5.3.4):
The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type.
So using a type name without parenthesis isn't legal.
Also,sizeofreturns an implementation defined value of the ty... |
The following prints the percentage of memory used.
```
printf (TEXT("There is %*ld percent of memory in use.\n"),
WIDTH, statex.dwMemoryLoad);
```
WIDTH is defined to be equal to 7.
What does TEXT mean, and where is this sort of syntax defined in printf?
|
As others already said,TEXTis probably a macro.
To see what they become, simply look at the preprocessor output. If are using gcc:
```
gcc -E file.c
```
|
```
#include <stdio.h>
void main()
{
int i = -3, j=2, k=0, m;
m= ++i|| ++j && ++k;
printf("%d%d%d%d", i, j, k, m);
}
```
If we see order of evaluation in++i|| ++j && ++k;we will come up with evaluation of++j && ++kat first it will increment value of j and k and it will evaluate as 1 af... |
||and&&are short-circuiting operators. They don't evaluate the second operand if it is not necessary to determine the output.
Here,++ievaluates to a non-zero value, which istruein a boolean context. The right-hand side is not evaluated at all.
|
The linux platform is Ubuntu 12.04
I have the following headers included in my source code:
```
#include <unistd.h>
#include <signal.h>
#include <ucontext.h>
...
```
When I compile it however, it complains/usr/include/x86_64-linux-gnu/sys/ucontext.h:139:5: error: unknown type name 'stack_t'
I googled and found th... |
This is meant to be a comment but I cannot make it readable there. Sorry.
Did you#defineone of the following:
```
_BSD_SOURCE || _XOPEN_SOURCE >= 500 ||
_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
|| /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
```
|
I'm trying to sort an array of pointers to words lexicographically and the sort itself seems to work, except of the swap, i tried many formats and i can't make it work, hope you could help me:
```
for(i=1;i<words;i++){
for(j=i;j>0 && strcmp(dicArray[0][j-1],dicArray[0][j]) == 1;j--){
temp = dicArr... |
Your swapping algo is not correct.
If you want to swapdicArray[0][j-1]anddicArray[0][j], then do the following:
```
temp = dicArray[0][j];
dicArray[0][j] = dicArray[0][j-1];
dicArray[0][j-1] = temp;
```
|
This question already has answers here:ARC forbids Objective-C objects in structs or unions despite marking the file -fno-objc-arc(4 answers)Closed9 years ago.
That's the problem, when I try to build my xcproject xcode show me an error on the 3rd row of the following code :
```
typedef struct
{
NSArray *array;
... |
I had simmilar issue and I sorted it by added__unsafe_unretainedkeyword like that:
```
typedef struct
{
__unsafe_unretained NSArray *array;
__unsafe_unretained NSString *string;
}WYnot;
```
Try it should help.
|
I try to compile a dummy AVX2 program on my Mac OS 10.9 with gcc version 4.9.0 20131201
```
//dummy program
#include <immintrin.h> // AVX2
#include <stdio.h>
int main(int argc, char* argv[]) {
__m256i reg = _mm256_set1_epi8(1);
__m256i result = _mm256_max_epu8(reg,reg);
printf("%d",((int *)&result)[0]);
}
`... |
To compile for a target with AVX2, use-mavx2.
|
Im sure Im missing something simple, and obvious, but I am tired of searching for the answer. Im using aPIC16F688andXC8compiler.
The compiler user manual says that there is adelay function __delay_ms(). It says that_XTAL_FREQmust be defined.
Here is my code, but it does not accept the command. What is wrong?
```... |
They are right, the problem was experienced by older versions of the IDE's. I have found it helpful to use:
```
while(1){
//Invert LED state
LED = !LED;
//Delay ~1 second (4MHz Internal Clock)
_delay(1000000); //specify clock cycles directly
}
```
To solve the problem.
|
I want to create a struct with 2 variables, such as
```
struct myStruct {
char charVar;
int intVar;
};
```
and I will name the structs as:
```
struct myStruct name1;
struct myStruct name2;
```
etc.
The problem is, I don't know how many variables will be entered, so there must be infinite nameX structures.
So, ho... |
You should use an array and a pointer.
```
struct myStruct *p = NULL;
p = malloc(N * sizeof *p); // where N is the number of entries.
int index = 1; /* or any other number - from 0 to N-1*/
p[index].member = x;
```
Then you can add elements to it by usingreallocif you need to add additional entries.
|
I need to know the width(size) of a native int in the system which my code is being run, in bits.
I can get the width in chars using "sizeof", however, it is my understanding that no-where in the C spec does a char have a specific number of bits assigned to it.
So what is the best cross platform method for finding t... |
CHAR_BIT(from<limits.h>) is the number of bits in achar, so
```
sizeof(int) * CHAR_BIT
```
is what you are looking for.
CHAR_BITis specified in "5.2.4.2.1 Sizes of integer types "
of the C99 standard.
Added:It might be interesting that the Open Group specification
http://pubs.opengroup.org/onlinepubs/7999959899/b... |
Is it possible to modify an environment variable within a C program. Something like this:
```
#include <stdlib.h>
int main( void )
{
system( "echo $VARIABLE" );
system( "VARIABLE=somethig");
system( "echo $VARIABLE" );
return 0;
}
```
|
Usesetenv()orputenv(). Beware the gotchas withputenv().
Your code as written sets the environment of a new shell interpreter spawned by call tosystem(). That environment is discarded whensystem()returns.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.