Hey,
I'm trying to get started with GLFW on Debian, I've tried compiling and running an example program but it refuses to run. With the help of a couple of printf statements I've found that when the program tries to open a GLFW window it fails, then exits - but I don't know why. Any help would be amazing.
#include <stdlib.h> // For ...
What is the best algorithm to achieve the following:
0010 0000 => 0000 0100
The conversion is from MSB->LSB to LSB->MSB. All bits must be reversed; that is, this is not endianness-swapping.
...
I am trying to replace last 2 digits of a integer with 38. I am doing that like below.
int num = 1297;
num = (num/100)*100 + 38;
What i am assuming is that compiler won't optimize (num/100)*100 to num. If that happens then in my above example, num will become 1335 instead of 1238. So, is it guaranteed in C that the above expression wo...
I'm running into an odd problem with concatenating or printing strings. I have a char * that can be set to one of a few values of string literal.
char *myStrLiteral = NULL;
...
if(blah)
myStrLiteral = "foo";
else if(blahblah)
myStrLiteral = "bar";
And I have some other strings that I get from library functions or that are concate...
I know there are startup folders and certain registry keys I need to look into. But how to do that using Windows API? I'm interested to know for Windows XP and Vista. Thanks for your time.
...
Can anyone confirm what the standard says about the default return type of vararg function. I was compiling the following code:
int main()
{
maw(32,3,95,38,20,15);
return 0;
}
int maw(int a,int b,...)
{
int *p=&b,i=0;
while(i++<a)
printf("\t%d",*p++);
return 0;
}
but it gave error:
foo.c:9: error: conflict...
I am working on a project which will be using large datasets (both 2D and 3D) which I will be turning into triangles, or tetrahedra, in order to render them.
I will also be performing calculations on these tris/tets. Which tris/tets to use for each calculation depend on the greatest and smallest values of their vertices.
So I need to ...
I have often thought about trying to learn a language like C++ to get a better understanding of computers. To me knowing C/C++ is like the black belt of programming. But then you look around at some great developers and I don't think that they have ever learnt C++.
Is it a good idea for some rainy day (more like rainy year) or should I...
Hi, I want to define a following function:
if(stmtToFinalize) {
NSLog(@"Finalizing statement stmtToFinalize");
if (sqlite3_finalize(stmtToFinalize) !=SQLITE_OK)
NSLog(@"An error occured while trying to finalize a statement stmtToFinalize: '%s'", sqlite3_errmsg(database));
stmtToFinalize = NULL;
}
But I am ...
We have a large, multi-platform application written in C. (with a small but growing amount of C++) It has evolved over the years with many features you would expect in a large C/C++ application:
#ifdef hell
Large files that make it hard to isolate testable code
Functions that are too complex to be easily testable
Since this code is t...
I'm reading about Type Equivalence in my Programming Languages class and I've come across a situation in C I'm unsure about.
It describes C's "Type Equivalence" as:
C uses a form of type equivalence that falls between name and structural equivalence, and which can be loosely described as "name equivalence for structs and unions, st...
I have a data structure like this:
struct foo {
int id;
int route;
int backup_route;
int current_route;
}
and a function called update() that is used to request changes in it.
update(42, dont_care, dont_care, new_route);
this is really long and if I add something to the structure I have ...
I recently was making a change to to our codebase from float to long for some variables, and discovered that there were no error messages generated by the compiler in areas I knew were still wrong. This led me to add -Wconversion to the compiler flags. But, oops, this leads to some spurious error messages. In the snippet below, I get er...
I am writing a daemon running on an embedded platform that needs to change the default route of the device according to which interface it is connecting on at a given time. How can I do this programatically? I know I can use system("route del default && route add default gateway blah"); etc but is there a more direct way?
UPDATE: I so...
I am studying for a test, and I was wondering if any of these are equivalent to free(ptr):
malloc(NULL);
calloc(ptr);
realloc(NULL, ptr);
calloc(ptr, 0);
realloc(ptr, 0);
From what I understand, none of these will work because the free() function actually tells C that the memory after ptr is available again for it to use....
A link is a pointer to a node
typedef struct node * link;
In main(), I have the following code (config->m is just some integer):
// array of pointers to structs
link heads[config->m];
// make memory for head nodes
for(i = 0; i < config->m; i++)
heads[i] = malloc(sizeof(struct node));
The code works (which is great). But is ther...
I looked through some code and noticed that the convention was to turn pointer types like
SomeStruct*
into
typedef SomeStruct* pSomeStruct;
Is there any merit to this?
...
I keep getting told that in this line of code passing argument from incompatible pointer type.
Here's the line of code:
if (linear_search (size_of_A, argv[i]))
What does this mean and how do I fix it? Here is the whole program:
int linear_search ( int size_of_A, char*argv[]){
int i;
i = 2;
while (i <= size_of_A - 1...
I need to know how big a given in-memory buffer will be as an on-disk (usb stick) file before I write it. I know that unless the size falls on the block size boundary, its likely to get rounded up, e.g. a 1 byte file takes up 4096 bytes on-disk. I'm currently doing this using GetDiskFreeSpace() to work out the disk block size, then using...
Gentlemen,
Does someone know where I can find a tutorial or material relating to Base24? I'm referring to Base24 the product by ACI. My understanding is that they use a programming language called 'TAL' which has similarities to Cobol and C.
I've searched the net and I have only found job opportunities for Base24 developers but hardly...