How can I make a switch case with run-time variables then?
Type: Posts; User: frs
How can I make a switch case with run-time variables then?
Why the following code doesn't give errors when I try to compile with gcc, and....
#include <stdio.h>
int x = 2;
const int y = 2;
switch(x)
{
Hmm, thank you once again.
so 14UL is the same as (unsigned long)14?? I'm talking about the syntax, 0UL, never seen a cast made that way.
Thank you.
Where can I find information about these conventions?
Can anyone explain this definition?
#include <stdint.h>
#include <stdbool.h>
#define NULL_BLOCK ((uint32_t)(~0UL))
Because the devices are treated much differently.
Yes yes. That's it.
That is what I was going to do, I never did compiler optimizations..
Probably I won't see any difference, but anyway is unnecessary to evaluate the switch statement in every...
I'm making a program to read data from USB Devices (gamepads and joysticks).
while(!poll_interrupt)
{
switch(dev_type)
{
case 1:
fetch data from dev1;
break
The idea was to assign an input parameter to the 'const char' , so it would have to be evaluated at least one time.
I'm not saying I believe, I'm asking.
What this has to do with the case?
print "1\n" in an infinite loop..
Edit Again.
Maybe I haven't expressed myself well.
Since n is a const variable, the compiler replaces the 'while' content into printf("1\n") only?
Edit. Sorry my bad.
In this piece of code the switch statement is evaluated only one time or not?
const int n=1;
while(1)
{
switch( n )
{
I have this statement inside a function, that opens a XML file.
static auto_ptr<Remote> remoteXML (Remote_("../config/remote_conf.xml"));
The XML file is opened every-time I call the function...
I'm attempting to read the messages sent by the child by forking, exec, and redirecting stdout. But the read messages are only printed after the child has finished, why this happens? Has something to...
here's my effort. I've redirected stdout of the child to a pipe. The resulting output is on below.I still have some problems..
1- Can anyone explain why the parent process only reads from the...
Can anyone explain the role of fflush in this code? The output is 0 .. 1 .. 2 til 9. When I remove the fflush, it prints 0 1 2 3 4 5 6 7 8 9 at once after 10 seconds. Why?
#include <stdio.h>...
When I fork() , the stdout and stdin are shared by both parent and child?
Thank you for the answers. WNOHANG returns immediately if no child has exited, I don't want that. The idea is forking, suspend the parent and exec( a program I can't modify ).
The exec program sends...
I've the following question.
pid_t pid = fork();
if(pid == 0) /* child */
{
if(execl("/usr/bin/sixad","sixad","-s",NULL)==-1);
{
if I use waitpid(), the calling process suspends its course until the child has terminated, isn't that correct?
(Using C on ubuntu)
In my program I need to fork a process and execute a .bin in the child process. Then I want to create a pipe that "connects" the stdout of the child to the stdout of the...
(Using C on ubuntu)
In my program I need to fork a process and execute a .bin in the child process. Then I want to create a pipe that "connects" the stdout of the child to the stdout of the...