c

C Pointers - Good Tutorials

Possible Duplicate: What are the barriers to understanding pointers and what can be done to overcome them? Was just wondering if anyone could "point me" to a good tutorial on pointers Would be very greatful Thanks ...

Question related to alignment

Is it a good practice to group all the variables of same type together while declaring in local scope within a function? If yes, why? Does it solve memory alignment issues? ...

Very Basic C Question

Can someone check my understanding and correct me if i am wrong? int p = 5; //create an int holding 5 int *ptr; //create a pointer that can point to an int *ptr = &p; // not sure - does this mean that my pointer now points to memory address five, or that the memory address my pointer points at contains 5? Sorry for the basic questio...

Dont understand this syntax

Given this loop, why is there a semi colon at the end? for(s = string; *s == ' '; s++) ; thanks edit * so is it possible to reverse this procedure so it starts at the end of a string and checks for a space and decreases until it finds a charachter? ...

Initializing an array of cstring inside a function call

How come I can do this: char sXSongs[20][30] = {"Song 1", "Song 2 (w/Blur)", "The End (It's Not Here Yet)"}; addAlbum(&list, "The Beatles", "Some Famous CD", 1960, sXSongs); But not this: addAlbum(&list, "The Beatles", "Some Famous CD", 1960, {"Song 1", "Song 2 (w/Blur)", "The End (It's Not Here Yet)"}); Is it impossible to initial...

Static vs global

if i have a c file like below #include<stdio.h> #include<stdlib.h> static int i; int j; int main () { //some implementation } What is the difference between i & j? ...

static memory vs heap memory?

Hi all, Im working in a memory restricted environment and need to create strings dynamically, but still have them not take up heap memory. So does this make sense: static char staticStringBuffer[10240]; static size_t staticStringWatermark = 0; void createString( const char * something, const char * somethingElse ) { char buf[1024]...

Recursive functions in C/C++

If we consider recursive function in C/C++, are they useful in any way? Where exactly they are used mostly? Are there any advantages in terms of memory by using recursive functions? Edit: is the recursion better or using a while loop? ...

Why can't I initialize an array of cstrings like this?

char sXSongBuffer[20][30]; sXSongBuffer = {"Thriller", "Don't Stop Till You Get Enough", "Billy Jean"}; Why does this return the error expected expression before ‘{’ token? The reason I want to initialize my array like this is so that I can change its contents like this later: sXSongBuffer = {"New Song", "More Music From Me"}; ...

C Arguments Not Working?

Why doesn't this work? When I try to use -l or -s as the first argument, the if statements don't take. They always go to the else statement. #include <stdio.h> #include <fcntl.h> #include <errno.h> #include <string.h> #include <stdlib.h> int main(int argc, char* argv[]) { if (argv[1] == "-l") { printf("Yay!\n"); } ...

Efficient string concatenation in C

Here's my problem: I have an array, which contains a command a[1], followed by several command args a[2], a[3], ... What I need to do is the following Create a string, consisting of the cmd and a combination of args E.g.: cmd arg1 arg2 arg3 Execute that command-string Here's how I woud do it (pseudo-code): Precompute the l...

reverse engineering c programs

every c program is converted to machine code, if this binary is distributed. Since the instruction set of a computer is well known, is it possible to get back the C original program? ...

Receiving packets for different MAC address.

Hello, is it possible to capture some packets in promiscuous mode (e.g. using winpcap) and than force OS (applications) to receive them as they were sent for our MAC? My observation is following. We can: capture all network traffic using promiscuous mode (winpcap) filter/modify the packets using firewall-hook/filter-hook send packe...

Extracting 'parts' of a hexadecimal number

I want to write a function getColor() that allows me to extract parts of a hexadecimal number entered as a long The details are as follows: //prototype and declarations enum Color { Red, Blue, Green }; int getColor(const long hexvalue, enum Color); //definition (pseudocode) int getColor(const long hexvalue, enum Color) { switch (C...

VFD display programming

I have a VFD display from Soundgraph and I want to know if there are some current API (C#, JAVA, C++, C, etc.) to program it. ...

Magic COLORREF/RGB value to determine when to use light/dark text

Years ago, in my long lost copy of Charles Petzold's Windows 3.0 Programming book, there was a magic COLORREF or RGB value documented that you could use to check whether you should draw text in a light colour or a dark colour. E.g. if the background colour was below this value, then use black text, if it was higher, use white text. Doe...

Obfuscating 'C' Language based binaries to avoid decompilation

Is there some way to obfuscate 'C' language based executables or libraries to prevent decompilaton? ...

How would you set a variable to the largest number possible in C?

How would you set a variable to equal infinity (or any guaranteed largest number value) in C? ...

OpenGL Calls Lock/Freeze

I am using some dell workstations(running WinXP Pro SP 2 & DeepFreeze) for development, but something was recenlty loaded onto these machines that prevents any opengl call(the call locks) from completing(and I know the code works as I have tested it on 'clean' machines, I also tested with simple opengl apps generated by dev-cpp, which wi...

Can I assume that two-dimensional arrays are initialized properly like this?

When I declare a two-dimensional array like this: char myArray[20][30] = {"ABC", "Is Easy As One Two Three"}; Can I assume that all other chars in this array are now set to \000? ...