The "yield" statement in python allows simple iteration from a procedure, and it also means that sequences don't need to be pre-calculated AND stored in a array of "arbitrary" size.
Is there a there a similar way of iterating (with yield) from a C procedure?
...
What are the reasons a malloc() would fail, especially in 64 bit?
My specific problem is trying to malloc a huge 10GB chunk of RAM on a 64 bit system.
The machine has 12GB of RAM, and 32 GB of swap.
Yes, the malloc is extreme, but why would it be a problem? This is in Windows XP64 with both Intel and MSFT compilers. The malloc sometim...
If I want to allocate a char array (in C) that is guaranteed to be large enough to hold any valid absolute path+filename, how big does it need to be.
On Win32, there is the MAX_PATH define. What is the equivalent for Unix/linux?
...
I've only used higher-level languages (Perl, Python, Java) for projects at work and at school, and I've only tinkered with C++ and C enough to fix bugs or add some classes to a project.
I've read The C Programming Language and grok it, and I'm an avid Linux user. I want to immerse myself in C by working on something other than a toy pro...
Hello; I'm working on a couple of C projects and I'd like to use automated theorem proving to validate the code. Ideally I'd just like to use the ATP to validate the functions contracts. Is there any functionality in C/gcc or external software/packages/etc that would enable design-by-contract style coding?
If not then thats just incen...
I have the following two structs:
The problem is the sizeof(Content) returns 160. The struct consists of 11 shorts, 6 ints, 76 chars, 7 floats, 1 double, totally adding to 158 bytes. I have counted three times and there is still a 2 byte difference.
typedef struct TIME_T {
short year,mon,day;
short hour,min,sec;
} TIME;
typ...
If I try to open an invalid TIFF file with TIFFOpen(), the function returns NULL. For some reason, the error handler isn't called. However, the file remains open, so I can't delete/overwrite it from the same process.
I tried using TIFFFdOpen(), so that I can close the handle myself, but for some reason it gives me this error on valid TI...
I am interested in learning how to write extremely efficient network server software and I don't mind getting my hands dirty with pointers, sockets and threading. I'm talking a server being able to handle thousands of concurrent connections. There is not much processing for each client, but a little.
Do you know of any code examples for...
Hello,
I have a binary file with variable length record that looks about like this:
12 economic10
13 science5
14 music1
15 physics9
16 chemistry9
17 history2
18 anatomy7
19 physiology7
20 literature3
21 fiction3
16 chemistry7
14 music10
20 literature1
The name of the course is the only variable length record in the f...
Hi guys, I've been trying to get a HUD texture to display for a simulator for a while now, without success.
First I bind the texture like this:
glGenTextures(1,&hudTexObj);
gHud = getPPM("textures/purplenebula/hud.ppm",&n,&m,&s);
glBindTexture(GL_TEXTURE_2D,hudTexObj);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexPa...
I need to write a small program for the university. The problem is, it has to be in C/C++ under linux, and I've never used linux, I anticipate having a lot of problems with the IDE, compilation, and all that.
Is it possible to code it under windows and then "copy/paste" the code and compile it under linux? What are limitations I should ...
How do you determine the length of an unsigned char*?
...
I'm on a system with no access to disk. My C program has in memory the contents of a valid, small, sqlite3 file (received over the network). I would like to use sqlite3's C API to open and access this file (read-only is fine).
How do I do this? I know I can create an empty in-memory database with
sqlite3_open(":memory:", &foo)
but is...
I have an unsigned long long that I use to track volume. The volume is incremented by another unsigned long long. Every 5 seconds I print this value out and when the value reaches the 32 bit unsigned maximum the printf gives me a negative value. The code snippet follows:
unsigned long long vol, vold;
char voltemp[10];
...
& has &&. | has ||. Why doesn't ^ have ^^?
I understand that it wouldn't be short-circuiting, but it would have different semantics. In C, true is really any non-zero value. Bitwise XOR is not always the same thing as logical XOR:
int a=strcmp(str1,str2);// evaluates to 1, which is "true"
int b=strcmp(str1,str3);// evaluates to 2, whic...
I have the following function
void initBoard(int * board[BOARD_ROWS][BOARD_COLS]){
int z = 0;
for( z = 0; z<10; z+=1){
int l;
for( l = 0; l<10; l+=1){
board[z][l] = 0;
}
}
}
and from main i call it like
int plBoard[10][10];
initBoard(&pcBoard);
when compiling it works but i get a warning saying: war...
On pg. 109 of K&R, we see:
void writelines(char *lineptr[], int nlines)
{
while (nlines -- > 0) printf("%s\n", *lineptr++);
}
I'm confused about what *lineptr++ does exactly. From my understanding, printf requires a char pointer, so we provide that with *lineptr. Then we increment lineptr up to the next char pointer in the array? Is...
I'm implementing a session store for a web-server. Keys are string
and stored objects are pointers. I tried using map but need something
faster. I will look up an object 5-20 times
as frequent than insert.
I tried using hash-map but failed. I felt like I got more constraints than more free time.
I'm coding c/c++ under Linux.
I don't...
How can I execute SQL statements from a C program. For example I want to display the output of select * from EMPfrom a c program. Do I need to do it using Stored Procedures? Do I need any library files to do it. My C compiler is Tiny C Compiler and I am currently having SQL server studio 2005. Suggestions for Unix/AIX platform + GCC are ...