During the last 2 months I've been trying to learn the basics of game programming. So I coded a few simple games in Java to learn the fundamentals, such as Tetris, Checkers and Pac-Man.
Now I want to learn/improve my skills in C, so I have this idea of writing those games in C to learn more about memory management, no OOP, etc. I have d...
Hi,
I thought a C string can be initialized with one and only one quoted string. I just wonder how is this correct?
char const help_message [] =
"Usage: %s [options] files ...\n"
"\n"
"Options include:\n"
" --verbose -v Be verbose\n"
" --help -h Print this help message\n"
" --output -o ...
Hey!
I'm trying to help a friend in a college assignment, but i kind of forgot a lot of C an Lex.
The thing is, we are trying to parse a HTML and a correspondent CSS file and add to a tag it's style.
Eg:
HTML
<body>
</body>
CSS
body{color:black;}
modified HTML
<body style="color:black;">
</body>
All the regex are done and ...
I am running ubuntu 9.10 (karmic koala), and I took a look at the jmp_buf structure which is simply an array of 12 ints. When I use setjmp, and pass in a jmp_buf structure -- 4 out of 12 entries are saved off. These 4 entries are the stack pointer, frame pointer, program counter and return address. What are the other 8 entries for? Are t...
All,
This has been bugging me for a while now. In C\C++( i guess java and .NET as well) we do not have to specify the row index in a multi-dimensional array.
So, for example i can declare an array of ints as such:
int Array[][100];
I think static arrays in general are represented as contiguous memory on the stack. So, taking a column...
Hello, How would I compile a file through notepad++, is there away i can invoke the compiler (gcc) and pass through the file onto gcc?
i have gcc in C:\Program Files\gcc
...
Hey all,
Quite a specific question, but I was wondering if anyone has had any problems getting the first signal to be caught in a consumer-producer relationship with multiple consumers (HTTP web server)
for(i = 0; i < num_threads; i++) {
pthread_cond_init(&condVars[i], NULL);
if(strcmp(policy,"FIFO") == 0)
pthread_create(&threadArr...
I have heard about the following scenario right when I started programming in C.
"Trying to access from outside, a functions local variable will result in error (or garbage value). Since the stack gets cleared off when we return from the function"
But my below code sample prints a value of 50. I am compiling the code with latest GCC c...
I know about algorithms to allocate/deallocate a 2D array dynamically, however I'm not too sure about the same for 3D arrays.
Using this knowledge and a bit of symmetry, I came up with the following code.
(I had a hard time visualizing in 3D during coding).
Please comment on the correctness and suggest any better alternative (efficien...
I'm trying to set up a blocking socket to timeout after 16 ms of trying to recvfrom() on a port. Platform is Windows. I've looked at tons of examples online and it seems really simple I just can't seem to get it to work. Any help would be appreciated!
#include <winsock2.h>
#include <string>
#pragma comment(lib, "ws2_32.lib")
#defin...
can sum guide me to a link or a program for simple client and server c or c++ code to run on linux
The requirement is that should be able to send and receive messages.....
...
How do one read different records of data that are separated with semicolons into an array in C?
from textfile: Text One; 12.25; Text Two; 5; Text Three; 1.253
fopen ...
for(i = 0; i < nrRecords; i++) {
fscanf(myFile, " %[^;];", myRecords[i].firstText); /* Ok first text*/
fscanf(myFile, "%lf", &myRecords[i].myDouble1); /* But goes...
See, for example, here
http://stackoverflow.com/questions/139299/difference-between-dependency-injection-di-inversion-of-control-ioc
to remind yourself what IoC and DI are.
The question and answer here
http://stackoverflow.com/questions/820594/is-inversion-of-control-specific-to-oo-languages
suggests that it does not require an OO l...
How do you tokenize when you read from a file in C?
textfile:
PES 2009;Konami;DVD 3;500.25; 6
Assasins Creed;Ubisoft;DVD;598.25; 3
Inferno;EA;DVD 2;650.25; 7
char *tokenPtr;
fileT = fopen("DATA2.txt", "r"); /* this will not work */
tokenPtr = strtok(fileT, ";");
while(tokenPtr != NULL ) {
printf("%s\n", tokenPtr);
tokenPtr ...
I have read that C++ is super-set of C and provide a real-time implementation by creating objects. Also C++ is closed to real world as it is enriched with Object Oriented concepts.
What all concepts are there in C++ that can not be implemented in C?
Some say that we can not over write methods in C then how can we have different flavo...
Hi, I'm interested in measuring a specific point in time down to the nanosecond using c++ in windows. Is this possible? If it isn't, is it possible to get the specific time in microseconds at least? Any library should do, unless I suppose it's possible with managed code.
thanks
...
#include <stdio.h>
#include <stdlib.h>
void
getstr(char *&retstr)
{
char *tmp = (char *)malloc(25);
strcpy(tmp, "hello,world");
retstr = tmp;
}
int
main(void)
{
char *retstr;
getstr(retstr);
printf("%s\n", retstr);
return 0;
}
gcc would not compile this file,but after adding #include <cstring> I could use g++ to compile this...
I want to do DFS on a 100 X 100 array. (Say elements of array represents graph nodes) So assuming worst case, depth of recursive function calls can go upto 10000 with each call taking upto say 20 bytes. So is it feasible means is there a possibility of stackoverflow?
What is the maximum size of stack in C/C++?
Please specify for gc...
Hello everyone there...
I have a problem, suppose I have a given string: "best", the target string is suppose: "beast". Then I have to determine the number of operations to convert the given string to the target string, however the operations allowed are:
1. add a character to string.
2. delete a character.
3. swap two char positions. (...
i doint project about process realtime data from cyber glove( Virtual Hand ) . So i need to write some application that get realtime data from glove and feed to some algorithm. i don't know how to deal with process realtime data, anybody hav some resource?
...