Can you do something like this with a macro in C?
#define SUPERMACRO(X,Y) #define X Y
then
SUPERMACRO(A,B) expands to #define A B
I have a feeling not because the preprocessor only does one pass.
EDIT
Official gcc only. No third-party tools please.
...
I set out to get myself a neat C debugging macro, not really sure what I really wanted (and being clueless when it comes to macros) I turned to google. Some time later and I now think I know what I want, but not how it works. I haven't had much luck with getting decent information about macros and techniques for debugging.
What I've bee...
When I compile C code in recent version of gcc, I am getting the following warning:
Function is define but not used.
What can be the reason for this warning and how can I approach to resolve it?
...
This code should take an integer, create pipes, spawn two children, wait until they are dead, and start all over again. However, around the third time around the loop I lose my prompt to enter a number and it no longer prints the number I've entered. Any ideas?
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno...
Hi
I wanted to know how i can do '>>>' shifting of java in c/c++.
thanks
...
Hi
Could someone please tell us to print a char when receiving data as a struct? Here is an example:
...
struct rcv{
int x1;
float x2;
char *x3;
};
rcv data_rcv;
...
if (recv(socket, &data_rcv, sizeof(data_rcv), 0) < 0)
printf("recv() failed");
...
printf("x1 = %d\n", data_rcv.x1);
printf("x2 = %f\n", data_rcv.x2);
printf("x...
Hi I am trying to use C to implement a simple struct:
2 boxes, each contains different number of particles; the exact number of particles are passed in main().
I wrote the following code:
typedef struct Particle{
float x;
float y;
float vx;
float vy;
}Particle;
typedef struct Box{
Particle p[];
}Box;
void make_box...
Are there any stdin input length limitations (in amount of input or input speed)?
...
Hi all,
I want to know what disadvantage of scanf() exist.
In many of a sites I have read that using scanf will cause buffer overflow some times. What is the reason for that, and is there any other drawbacks with scanf?
...
The following code is a simple thread game, that switches between threads causing the timer to decrease.
It works fine for 3 threads, causes and Abort(core dumped) for 4 threads, and causes a seg fault for 5 or more threads.
Anyone have any idea why this might be happening?
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
...
#include<stdio.h>
int main()
{
printf("He %c llo",65);
}
Output: He A llo
#include<stdio.h>
int main()
{
printf("He %c llo",13);
}
Output: llo. It doesnt print He.
I can understand that 65 is ascii value for A and hence A is printed in first case but why llo in second case.
Thanks
...
Could somebody tell me the difference between:
int *p;
p=(int*)malloc(10*sizeof(int));
free(p);
or
int *p;
p=(int*)malloc(10*sizeof(int));
p=NULL;
...
This one is quite obviously a function pointer :
typedef int (* foobar) (int a, unsigned char *b, unsigned int c);
But what does this one do?
typedef int (foobar *) (int a, unsigned char *b, unsigned int c);
...
Hello!
I have a problem that I want to insert and delete some chars in the middle of a file. fopen() and fdopen() just allow to append at the end.
Is there any simple method or existing library that allow these actions? Thanks in advance.
...
Hi all !
What should be the buffer offset value for U & V in YUV444 format type?
Like for an example if i am using YV12 format the value is as follows:
ppData.inputIDMAChannel.UBufOffset =
iInputHeight * iInputWidth +
(iInputHeight * iInputWidth)/4;
ppData.inputIDMAChannel.VBufOffset = iInputHeight * iInputWidth;
iInput...
my code is
void doc(){
//mycode
return;
}
my warning is
conflicting types for 'doc'
can anybody solve it.
...
Hello,
I want to print on the screen the information about Top level windows under Linux.
I use the xlib functions. I successfully recurse from the root window to print all the informations about all the element on display.
But I need only the Top-Level window. I don't find any good way to filter.
From wikipedia :
The top-level w...
I have the following casting problem when my data structure sSpecificData contains a field of type tm:
typedef struct
{
unsigned char data[10000];
} sDataBuffer;
typedef struct
{
int m_Id;
sDataBuffer m_Data;
} sData;
typedef struct {
int m_value1;
int ...
I'm reading some C code like that:
double function( int lena,double xa,double ya, double za, double *acoefs, ...,
int lenb,double xb,double yb, double zb, double *bcoefs, ...,
same for c,
same for d )
This function is called in the code mor than 100.000 times so it's performance-criti...
i have a thread with return type DWORD in c but it is then handled by a HANDLE type pointer,
what is difference between these two types?
ok i am asking this question specially for ansi-c
it is right that DWORD is uint type and HANDLE is PVOID and c allows to cast directly DWORD to HANDLE but is there any difference in there types or ...