c

How to use a defined struct from another source file?

Hi, I am using Linux as my programming platform and C language as my programming language. My problem is, I define a structure in my main source file( main.c): struct test_st { int state; int status; }; So I want this structure to use in my other source file(e.g. othersrc.). Is it possible to use this structure in another sour...

Pointer to 2D array. Why does this example work?

I have this code example, but I don't understand why changing the values in the array inside outputUsingArray() are changing the original array. I would have expected changing the values of the array in outputUsingArray() would only be for a local copy of the array. Why isn't that so? However, this is the behaviour I would like, but ...

Sorting a 2 dimensional array on multiple columns

I need to sort a 2 dimensional array of doubles on multiple columns using either C or C++. Could someone point me to the algorithm that I should use or an existing library (perhaps boost?) that has this functionality? I have a feeling that writing a recursive function may be the way to go but I am too lazy to write out the algorithm or ...

Is Objective-C++ a totally different language from Objective-C?

As the title says... are they considered different languages? For example if you've written an application using a combination of C++ and Objective-C++ would you consider it to have been written in C++ and Objective-C, C++ and Objective-C++ or all three? Obviously C and C++ are different languages even though C++ and C are directly comp...

writing "%d" in a printf C

Hey, What is the correct syntax for this code: is it: printf("printf(\"\%d\",%s);", some_var); or printf("printf(\"%%d\",%s);", some_var); Or something else? ...

problem with fork()

I'm writing a shell which forks, with the parent reading the input and the child process parsing and executing it with execvp. pseudocode of main method: do{ pid = fork(); print pid; if (p<0) { error; exit; } if (p>0) { wait for child to finish; read input; } else { call function to parse input; exit; } }while condition return; ...

Generating Fibonacci Numbers Using variable-Length Arrays Code Compiler Error.

Compile error in vs2010(Win32 Console Application Template) for the code below. How can I fix it. unsigned long long int Fibonacci[numFibs]; // error occurred here error C2057: expected constant expression error C2466: cannot allocate an array of constant size 0 error C2133: 'Fibonacci' : unknown size Complete code attached(It's a ...

How to print %s in C?

I want to print "%SomeString%" in C. Is this correct? printf("%%s%",SomeString); ...

What is DEFAULT_CC in function declaration?

I'm relatively new to C, and am curious what this syntax means in a function declaration: int DEFAULT_CC foo(void) where DEFAULT_CC is probably defined somewhere else as: #define DEFAULT_CC "something" (I realized the previous example I had up had to do with something completely irrelevant). ...

How do I unpack bits from a structure's stream_data in c code?

Ex. typedef struct { bool streamValid; dword dateTime; dword timeStamp; stream_data[800]; } RadioDataA; Ex. Where stream_data[800] contains: **Variable** **Length (in bits)** packetID 8 packetL 8 versionMajor 4 versionMinor 4 radioID 8 etc.. I need to write: void unpackData(radioDataA *strea...

c/gtk convert structure to the type of GtkWindow

Hello I have structure: typedef struct _MainWin { GtkWindow parent; GtkWidget* scroll; GtkWidget* box; }MainWin; I created application main window from this structure. Now i need in main window full screen. When i try to call: gtk_window_fullscree(GTK_WINDOW(mw); Where mw is object of MainWin i see: **gtk_window_fullscr...

How do I execute a function from RAM on a Cortex-M3 (STM32)?

I'm trying to execute a function from RAM on a Cortex-M3 processor (STM32). The function erases the and rewrites the internal flash, so i definitely needs to be in RAM but how do I do that? What I have tried is this: Copy the function to a byte array in RAM using memcpy (checking that it gets aligned correctly), setting a function poin...

pointer is always byte aligned

Hi, I read something like pointer must be byte-aligned. My understanding in a typical 32bit architecture... all pointers are byte aligned...No ? Please confirm. can there be a pointer which is not byte-aligned ? Basically this is mentioned in a hardware reference manual for tx descriptor memory. ...

Books and shellcode examples

i read "art of exploitation" and "gray hat hackers".Both these books examples written for x86 systems.i have a centrino laptop and an amd64 pc.I can't make work examples for stack based overflow. ...

Take data from an XML file and put it into a MySQL database

Hi Guys, I'm looking to construct a script that would go through an XML file. Would find specific tags in it, put them in a table and fill the table with specific tags within them. I'm using MySQL 5.1 so loadXML isn't an option and I think that ExtractData() method wont be much use either.. but I don't really know. What would be the bes...

windows mobile - connection link failed

Windows mobile 6.1 device, attempting to connect via a mobile network and we sometime see the message "Connection Link failed". Can anyone verify what this actually means, I'm beginning to think it relates to signal from the mobile carrier but does anyone have any other ideas? ...

Segmentation fault on writing char to char* address

Hi guys, I've got problem with my little C program. Maybe you could help me. char* shiftujVzorku(char* text, char* pattern, int offset){ char* pom = text; int size = 0; int index = 0; while(*(text + size) != '\0'){ size++; } while(*(pom + index) != '\0'){ if(overVzorku(pom + index, pattern)){ ...

PDCurses TUI C++ Win32 console app - Access violation reading location

I have downloaded pdcurses source and was able to successfully include curses.h in my project, linked the pre-compiled library and all good. After few hours of trying out the library, I saw the tuidemo.c in the demos folder, compiled it into an executable and brilliant! exactly what I needed for my project. Now the problem is that it'...

howto create a filesystem like /proc?

I would like to create a pseudo filesystem like /proc to access an applications configuration. How could i achieve this or where could i find some introductory dokumentation about it? ...

program "is not up to date" execution error in wedit lcc-win32

I'm attempting to compile a simple hello world program in c with lcc-win32/wedit, and i'm a little unfamiliar with windows c programming. #include <stdio.h> int main(void){ printf("hellow\n"); return 0; } When I compile the program the console output is: Wedit output window build: Tue Jun 15 09:13:17 2010 c:\lcc\lib\lcccrt0.obj ...