c

what is architecture context diagram

pls help me for my project documentation by giving the information of architecture context diagram ...

call to C and c++ both in a single java program

hi all is it possible to declare to native methods in java so that one method is defined in c and other method is defined in c++.m getting confusion in it . please help me in this. ...

Why doesn't strncpy work with a string allocated with malloc?

char* temp; temp = (char*) malloc (strlen(window->entry.value)+1); //strncpy( temp, window->entry.value, sizeof(temp) ); DOESN"T WORK memcpy (temp, window->entry.value, strlen(window->entry.value) + 1); //WORKS (where window->entry.value is a string.) Thanks. ...

How to generate a boolean with p probability using C rand() function?

How can I generate a random boolean with a probability of p (where 0 <= p <= 1.0) using the C standard library rand() function? i.e. bool nextBool(double probability) { return ... } ...

How can I enable ctrl-c / ctrl+break after calling system?

I have written a program that invokes a system command from inside: #include <stdlib.h> int main(void) { while(1) { system("ls 2>&1 1>/dev/null"); // comment this line out to enable ctrl+break } return 0; } However, when it is running, CTRL+C and CTRL+BREAK no longer work and appear to be ignored. I am tryin...

Suggestions to improve a C ReplaceString function?

Hi, I've just started to get in to C programming and would appreciate criticism on my ReplaceString function. It seems pretty fast (it doesn't allocate any memory other than one malloc for the result string) but it seems awfully verbose and I know it could be done better. Example usage: printf("New string: %s\n", ReplaceString("great",...

Is it possible to output on screen the content of a certain memory address in a C program?

Hi, for debugging reasons, how can one in a C program print some memory address? For instance, how should I do to print the content of address 0x611268 in form of a 4 byte float ? I know I could use a debugger, but I mean, to print out in screen. Thanks ...

What does the prefix L"..." stand for in GCC C without #including wchar?

That is, why does unsigned short var= L'ÿ' work, but unsigned short var[]= L"ÿ"; does not? ...

How do I open a C file with a relative path?

I am trying to parse a txt file and I want to reference it relative to my current directory location. If I put the file path in completely it will work but it I try to use ..\src\test.txt it wont find it. Is this not the proper way to reference a file relative up one directory? Any help would be appreciated ...

How does this work? copying anything into an array of bytes (chars)

struct MyRect { int x, y, cx, cy; char name[100]; }; int main() { MyRect mr; mr.x = 100; mr.y = 150; mr.cx = 600; mr.cy = 50; strcpy(mr.name, "Rectangle1"); MyRect* ptr; { unsigned char bytes[256]; memcpy(bytes, &mr, 256); ptr = (MyRect*)bytes; } printf("X = %d...

Coding conventions for method returns in C++

Hello, I have observed that the general coding convention for a successful completion of a method intended functionality is 0. (As in exit(0)). This kind of confuses me because, if I have method in my if statement and method returns a 0, by the "if condition" is false and thereby urging me to think for a minute that the method had fa...

Defining an abstract type in C

Is it possible to have the array subscript before the variable name in declaration? For example, is it possible to have char [10]data; where the intended declaration is: char data[10]; I know that this might be stretching it a bit too much, but I have the variable type defined using #define, which I need to change from int to cha...

How would I replace the character in this example using strchr?

/* strchr example */ #include <stdio.h> #include <string.h> int main () { char str[] = "This is a sample string"; char * pch; printf ("Looking for the 's' character in \"%s\"...\n",str); pch=strchr(str,'s'); while (pch!=NULL) { printf ("found at %d\n",pch-str+1); pch=strchr(pch+1,'s'); } return 0; } How would I...

add a child to GtkVBox

Hi, I have problem while adding a child to a GtkVBox. The VBox is inside a GtkViewPort which is inside a ScrolledWindows. After the child it's added using gtk_box_pack_end I check if it's really added checking the GLIST and it appears that it's added. Although visually anything appears and the scrolled window gets really big. Like if...

Difficulties when attempting to create the Cartesian product of a pointer to char pointer

As input I have a pointer to char pointer containing: {"ab", "cd"} As output I need to create the following Cartesian product: {"abab", "abcd", "cdab", "cdcd"} I created a function that receives "ab, cd" and a pointer to char pointer that is meant to hold the resulting set. Although everything seems to be working fine inside the fu...

Is there a way to access debug symbols at run time?

Here's some example code to give an idea of what I want. int regular_function(void) { int x,y,z; /** do some stuff **/ my_api_call(); return x; } ... void my_api_call(void) { char* caller = get_caller_file(); int line = get_caller_line(); printf("I was called from %s:%d\n", caller, line); } Is there a w...

argv[argc] == ?

My professor and a couple of students are arguing about if argv is null terminated or not. My friend wrote a small program and it printed out null but another kid is saying that he is probably just reading into blank memory. Can someone solve this discussion? -Jake ...

struct and typedef

Are the following equivalent in C? // #1 struct myStruct { int id; char value; }; typedef struct myStruct Foo; // #2 typedef struct { int id; char value; } Foo; If not, which one should I use and when? (Yes, I have seen this and this.) ...

C shared library question

Background: I'm trying to develop a simple game similar to Zelda (NES) in C as a way to learn C. I've come to the conclusion that having all of the game data in a single file is not ideal. So what I'd like to do is break up each "area" into it's own module. This "area" module will describe to the main program its properties, such as ...

Why does the malloc fail?

A pointer expected error occurs when the compiler it gets to the assignment at the at end of the function. Why? (Removed casts and index notation from code; they were there for "debugging" buy apparently cluttered my question.) int createArraySimple(int initialResetCount, int ***array) { int sourceTermIndex, driveCurrentIndex, preE...