Hi,
I'm having a little trouble with this. First of all, this is for a simple graphics library that I was writing.
What I'm doing is making it possible to declare multiple "virtual screens", with dimensions of the programmer's choice. For this, I need to dynamically allocate enough memory based on the number of pixels the screen will c...
I have to analyze a 16 GB file. I am reading through the file sequentially using fread() and fseek(). Is it feasible? Will fread() work for such a large file?
...
How do I write this C expression in J? (where x is input integer, and a is temporary variable)
((a= ~x & (~x >> 1)) ^= a ? 0 : (a ^ (a & (a - 1))) | (a ^ (a & (a - 1))) << 1);
.
Edit:
In a more readable form:
int a = (~x) & ((~x) >> 1);
if (a == 0) return 0;
int b = a ^ (a & (a - 1));
return b | (b << 1);
...
I'd like to optimize the following snippet using SSE instructions if possible:
/*
* the data structure
*/
typedef struct v3d v3d;
struct v3d {
double x;
double y;
double z;
} tmp = { 1.0, 2.0, 3.0 };
/*
* the part that should be "optimized"
*/
tmp.x /= 4.0;
tmp.y /= 4.0;
tmp.z /= 4.0;
Is this possible at all?
...
I would like to be able to do something like
#print "C Preprocessor got here!"
for debugging purposes. What's the best / most portable way to do this?
...
C's memory model, with its use of pointer arithmetic and all, seems to model flat address space. 16-bit computers used segmented memory access. How did 16-bit C compilers deal with this issue and simulate a flat address space from the perspective of the C programmer? For example, roughly what assembly language instructions would the f...
I'm using cURL to scrape web pages but I can only seem to scrape top-level URLs. For example, if I want to cURL the URL "http://www.businessweek.com/news/2010-09-29/flaherty-says-canada-july-gdp-report-tomorrow-may-be-negative.html" then it returns nothing (as if it's a blank page).
This is my C code:
#include <stdio.h>
#include <curl/...
#include <stdio.h>
typedef struct point{
int x;
int y;
};
void main (void){
struct point pt;
pt.x = 20;
pt.y = 333;
struct point pt2;
pt2.y = 55;
printf("asd");
return;
}
VS 2008
c:\documents and settings\lyd\mis documentos\ejercicio1.c\ejercicio1.c\ejercicio1.c(14) : error C2143: syntax erro...
Hello, I need to do some process synchronization in C. I want to use a monitor, and I have read a lot about them. However I have been unable to find out how to implement one in C. I have seen them done in Java and other languages like C++, but I am unable to find examples in C.
I have looked through K&R and there is no example in there...
I'm trying to make a key logger for Mac OS for one of my research projects.
I have a C code which will grab keystroke and write them to a text file. (The following code I have taken out some not important stuff)
What I need to do now is just like PyHook, instead of write the data to a text file,
to pass a Python callback function to th...
I am experimenting a little bit with gamestudio.
I am making now a shooter game.
I have an array with the pointer's to the enemies. I want. to when an enemy is killed. remove him from the list. And I also want to be able to create new enemies.
Gamestudio uses a scripting language named lite-C. It has the same syntax as C and on the webs...
Adding file information to a program.
/**
* @Author: Kyle
* @Date: 9-29-2010
* @Description: Stack overflow question!
*/
Am I doing this right? I have a C programming course and I've been authoring my programs with something similar to that.
Also... Where would I include version information for a file? Would I include it under the da...
Is there a fast way to do that?
...
I am using cscope to get familiar with all the keywords used in socket programming. I went to the directory with c files. I used cscope. and then I searched for AF_INET. I got this :
#define AF_FILE PF_FILE
#define AF_INET PF_INET
#define AF_AX25 PF_AX25
This was a full page. I only published part of it. Now I ...
Hello,
I am not able to found a solution to my problem online.
I would like to call a function in Unix, pass in the path of a directory, and know if it exists. opendir() returns an error if a directory does not exists, but my goal is not to actually open, check the error, close it if no error, but rather just check if a file is a direc...
What are various ways in C/C++ to define a string with no null terminating char(\0) at the end?
EDIT: I am interested in character arrays only and not in STL string.
...
getLine is a function that gets a line, I'm trying to combine lines together outside the getLine function. When ever I try doing this in a loop it messes up the output. I bet it has to do with the pointers, but I have spend many hours trying to figure it out.
int num;
int matrix[370];
i=1;
j=0;
while(*(point=getLine(infile)) ...
As I know that in C we could use the keyword "register" to suggest to the compiler that the variable should be stored in the CPU register. Isn't it true that all variables that involved in CPU instructions will be eventually stored in CPU registers for execution?
...
Can anyone tell me how to return multiple values from a function?
Please elaborate with some example?
Thanks in advance
...
I am attempting to parse a text (CSS) file using fscanf and pull out all statements that match this pattern:
@import "some/file/somewhere.css";
To do this, I have the following loop set up:
FILE *file = fopen(pathToSomeFile, "r");
char *buffer = (char *)malloc(sizeof(char) * 9000);
while(!feof(file))
{
// %*[^@] : Read and discar...