Say you have:
struct c_struct {
int value;
/* other stuff */
void (* dump)();
};
and you'd like to, at some point:
c_struct_obj->dump();
I assume there's no way you could instantiate a c_struct object such that its particular "dump" function knows its particular "value" the way C++ methods know member variables (via the im...
Many times I need to do things TWICE in a for loop. Simply I can set up a for loop with an iterator and go through it twice.
for (i = 0; i < 2; i++)
{
// Do stuff
}
Now I am interested in doing this as SIMPLY as I can, perhaps without an initializer or iterator ... or any really simple and elegant way ...
How would you do it?
x
...
When this program is run, the "stderr" line is displayed before the "stdout" line. Why? I thought dup2 would make stderr and stdout use the same file descriptor so there should be no problem with buffering. I'm using gcc 3.4.6 on Solaris 10.
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
int fd[2];
int p...
I have an ANSI C code that is about 10,000 lines long that I am trying to use in an iPhone project. When I compile the code with gcc on the command line, I type the following:
gcc -o myprog -O3 myprog.c
This program reads in large jpeg files and does some fancy processing on them, so I call it with the following
./myprog mypic.jpg
a...
Platform: Linux, OSX
Compiler: GCC
I've got a simple program which is currently confounding me - I know that I'm messing with a couple different kinds of arrays/pointers to produce this problem - its intentional - I'm trying to understand it.
The code as listed will compile and run as expected, but changing data4 in the call to strsep(...
I am making a function that turns a list of words into an array to be used by other functions, but somehow I'm overwriting previous words. I check the memory address' and they seem different, but when I recheck once I'm done importing the words, they are all the same.
static char **array;
//takes the name of a data file and reads it in...
I have a randomly ordered C array of integer numbers.
Each of these numbers represents a color, and has its relationship to every other number in the array defined elsewhere (they are non-linear, and are based on both the brightness of the color and the hue).
I need a quick, efficient algorithm to sort these numbers based on their ...
this
en.wikipedia.org/wiki/Hot_swapping#cite_note-1
says that VS can do it with the help of its debugger. Does gdb provide a similar functionality ?
this is the closest i could find, but doesn't seem to be ready to be used:
http://www.aitdspace.gr/xmlui/handle/123456789/219
dlopen/dlsym/dlclose are also close, but will not work for ...
Is there a way to find out if a socket is already in Non-Blocking mode in Windows?
I know this can be done in case of Linux, but, I am unable to find any way for this Windows.
All my coding is in 'C' language. Is there a way?
...
Here was my original code:
#include <stdio.h>
#define IN 1 // inside a word
#define OUT 0 // outside a word
// program to print input one word per line
int main(void)
{
int c, state;
state = OUT;
while ((c = getchar()) != EOF) {
if (c == ' ' || c == '\n' || c == '\t') {
state = OUT;
printf("\n");
}
...
I'm not looking for the answers to be given to me, just some direction on what I need to look at to get started.
/* copyLSB - set all bits of result to least significant bit of x
* Example: copyLSB(5) = 0xFFFFFFFF, copyLSB(6) = 0x00000000
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 5
* Rating: 2
*/
int copyLSB(int x)
{
return 0;
...
I was trying to develop a chat application using C programmable sockets. I need to check whether the stdin buffer has some value in it to send the message to the client/server and receive it. But I don't know how to check the stdin buffer for values.
Please help.
...
i have been asked in a interview question to change the entry point of a c or c++ program from main() to any other function how is it possible?
thanx in advance.
...
I want to create a project file turbo c++ and link the files in this project. Although i have tried for it but i found only one option that to open a project no option to create a new project. So How to do that
Thanks in advance.
Saurabh Mehta.
...
I'm programming in C. I'm getting the following error:
ctc E208: ["..\..\ECB\Include\ecb.h" 4/11] syntax error - token ";"
inserted before "u8_vTeethBeforeMissingTeeth1"
Here is what I have in the .h file:
#ifndef __ECB_H__
#define __ECB_H__
extern u8 u8_vTeethBeforeMissingTeeth1;
extern u8 u8_vTeethBeforeMissingTeeth2;
#endif /* ...
I want to read in a string and parse it with sscanf. Although i don't want to read in any spaces in the beginning.
Sample string.
@a Bear Tiger
sscanf(strLine, "@%1s %64s %64s", dir, name1, name2);
I have that.
Problem is if the line goes in as say
@a Bear Tiger
Should be:
@a Bear Tiger
that it will want to read in th...
Is there a good way to loop over a string with sscanf?
Let's say I have a string that looks like this:
char line[] = "100 185 400 11 1000";
and I'd like to print the sum. What I'd really like to write is this:
int n, sum = 0;
while (1 == sscanf(line, " %d", &n)) {
sum += n;
line += <number of bytes consumed by sscanf>
}
but t...
I'm trying to embed python into c to use it for configuration:
If I do it like this:
/******************************************************************************
*
* Embeding Python Example
*
* To run:
* gcc -c test.c -o test.o -I"C:/Python25/include"
* gcc -o test.exe test.o -L"C:/Python25/libs" -lpython25
* test.exe
*
****...
I am writing a C program that is expected to be compiled with all major compilers. Currently I am developing on GCC on a linux machine and will compile on MSVC before committing the code. To make the cross-compiling easy, I am compiling with -ansi and -pedantic flags. This worked well until I started using snprintf which is not available...
are pointers of integer or unsigned datatype?
...