GCC complains if i do this:
#define M(obj,met, ..., contents) obj##_##met(const void * self, __VA_ARGS__) { \
contents \
}
Giving me these 2 reasons:
error: missing ')' in macro parameter list
warning: __VA_ARGS__ can only appear in the expansion of a C99 variadic macro
Apparently, C99 - style variadic macros expect the clos...
I wish to take an integer as a command line argument, but if the user passes a non-integer string, this will cause a stack overflow. What is the standard way to ensure atoi() will be successful?
...
When we reallocate memory via realloc(), are the previous contents over-written? I am trying to make a program which reallocates memory each time we enter the data into it.
Please tell me about memory allocation via realloc, is it compiler dependent for example?
...
Hi
I'm studying for my test in C and i've encountered a question which i can't figure its answer.
A programmer wrote a program to count number of users (Count.h, Count.c):
/******** FILE: Counter.h ***********/
static int counter = 0;
int getUsersNum ();
/******** END OF FILE: Counter.h ****/
/******** FILE: Counter.c ***********/
#...
Hi,
I'm working on a cluster analysis program that takes a set of points S as an input and labels each point with that index of the cluster it belong to. I've implemented the DBScan and OPTICS algorithms and they both work as expected.
However, the results of those algorithms can be very different depending on the initial values of MinP...
I have a program that goes n^2 layers deep of recursion and mallocs a bunch of memory to concatenate char*s together. With a large enough n, the process just gets killed by the server (since it is consuming too much memory). How can I release this memory and still have my data?
It's mallocs look like
test = (char *)malloc(sizeof(cha...
Similar to: http://stackoverflow.com/questions/3250957/finding-the-largest-palindrome-of-the-product-of-two-three-digit-numbers-problem
The IsPalindrome condition always is true.Please guide me to the error.
#include <stdio.h>
#include <malloc.h>
int IsPalindrome(int num);
int main()
{
int i,j,temp;
for(i=10;i<99;i++)
{
...
void func( int *p)
{
// Add code to print MEMORY SIZE which is pointed by pointer P.
}
int main()
{
int *p = (int *) malloc (10);
func(p);
}
How can we find MEMORY SIZE from memory pointer P in func() ?
...
I am trying to input a string of characters, and then output them backwards like
Input: Hello
Output: olleH
I have a working example, however I am getting every single letter except the last.
#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 100
int main(void) {
int my_stg2[MAX_SIZE];
int i = 0;
int j;
char my_stg[MAX_SIZE];
...
When I call kill(Child_PID, SIGSTOP); from the parent, I expect the child to halt execution and the parent to continue. Is that the expected behavior or do I have to explicitly declare the SIGSTOP handler in the child? I have searched everywhere and not been able to find this information.
Thanks.
Braden
...
difference between enumerated and structure.
...
I tried this but it does not work
LPWSTR test = L"C:\\Users\\Default\\wallpaper.png";
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, test, SPIF_UPDATEINIFILE);
...
I was wondering if there is a way to intercept and modify mouse input before it gets to windows?
What I'm wanting to do is intercept mouse motion events, apply some custom scaling and acceleration to the values, and then continue passing them along. I'd need something that can do this before the inputs get to the raw input API or Direct...
I'm working on a 'C' code base that was written specifically for one type of embedded processor. I've written generic 'psuedo object-oriented' code for things like LEDs, GPIO lines and ADCs (using structs, etc). I have also written a large amount of code that utilizes these 'objects' in a hardware/target agnostic manner.
We are now tos...
I saw the code on the top of a GLUT demo and I'm curious about its functionality.
Why would someone want to write a #pragma instead of just including the library?
...
Bad style notwithstanding, is it legal C to have a for loop with braces inside the parens? Like this:
char *a = "a ";
char *b = "b ";
for ( { int aComesFirst = 1;
char *first = a;
char *second = b;
};
aComesFirst >= 0;
{ aComesFirst--;
swap(first, second);
} )
{
printf("%s%s\n", first,...
Okay, this is possibly a stupid question but here goes:
In C, is it enough to just use free() on the pointer return by malloc, even though the memory-area allocated by malloc may be huge and might have been casted into different types and structs etc.?
...
Just started learning C from Cocoa developing guide and I was wondering how (if at all possible) I would return the result of a function with multiple variable types. For example, I have a simple math function that I made to practice what I am reading and I gave it multiple variable types:
#include <stdio.h>
float doMath (int variable...
char lpszUsername[255];
DWORD dUsername = sizeof(lpszUsername);
GetUserNameA(lpszUsername, &dUsername);
ret_status = NetUserGetInfo(pc_name, lpszUsername, 1, (LPBYTE*)&ui);
So I need char for GetUserNameA, but for NetUserGetInfo - LPCWSTR.
WTF?
How do I can convert char to this?
error C2664: 'NetUserGetInfo' : cannot convert parameter...