c

Write a program to check if a character forms an escape character in C.

I was trying to check whether or not an alphabet perpended by a \ would form an escape character in C. What would be the easiest way to check this? I tried to append "\" with ASCII of the character set but it failed Edit: I dont want to manually append the characters. If I could somehow iterate within the ASCII values and append and ...

what type of connect better use for redis ?

I want to use redis in my server application ( c module for nginx ) - ( check variable from redis for each request ). what should I use type of connection ( keep alive or separate connection for each request ( connect, do, close ) ) to redis ( I plan to use credis for connect to redis )? I use 2 servers. ...

A program to control memory for a task in C

Hi I have got a task to solve, that is a bit cryptic. The task is to make a program in C that handles texts messages, the program should simulate a system with a small amount of memory, the system should only be able to hold X messages with maximum X characters, every character takes 1 byte (ASCII). To manage messages should I make a sy...

How does a sorting network beat generic sorting algorithms?

In reference to fastest sort of fixed length 6 int array, I do not fully understand how this sorting network beats an algorithm like insertion sort. Form that question, here is a comparison of the number of CPU cycles taken to complete the sort : Linux 32 bits, gcc 4.4.1, Intel Core 2 Quad Q8300, -O2 Insertion Sort (Daniel S...

VTK swap out rendering codeblock?

Hi, since some days I'm working with the VTK and I need some help. Is it possible to swap out the rendering codeblock?Like this: void display(XXXXXX) { vtkActor actor = new vtkActor(); actor.SetMapper(XXXXXXX); vtkRenderer ren2 = new vtkRenderer(); ren2.AddActor(actor); vtkRenderWindow ren...

Reading a dicom file in C

How do I read a dicom file, with different tags, in C? ...

Linked list insertion sort

I'm not very advanced in the sorting part of programming yet, so I was looking for some help with my algorithm. void sortList() { Item_PTR tmpNxt = current->nextItem; Item_PTR tmpPTR = current; int a, tmp; while(tmpNxt != NULL) { a = tmpPTR->value; while(tmpNxt != tmpPTR && tmpNxt->value < a) ...

Beginner Code::Blocks 10.05 Project vs. Program terminology and IDE issues

Here is the basic issue: when I use codeblocks to begin a "project" (they use this term as opposed to program...) I start with a console "project" and C::B immediately includes a file "main.c" file... with Hello world... the funny thing is the program name that I want to use is (example) would be something like Rick_practice.c for the so...

How do I write an echo program in C?

the output should be something like this: Enter Character : a Echo : a I wrote int c; while (c != EOF) { printf("\n Enter input: "); c = getchar(); putchar(c); } But I get two Enter Input after the echos. ...

Converting expression to Parse tree using C or C# Code

Hi, I want to make a C or C# code that will be used to convert from some expressiont to do some work such as like Addition or sub. ...

Non-blocking native files access - single-threaded daemon in C?

I've found out that native files access has no "non-blocking" state. (I'm correct?) I've been googling for daemons which are "non-blocking", and I've found one which achieved said behavior by threading file access operations, so that the daemon won't block. My question is, wouldn't threading and IPC'ing such operations be rather expens...

How do compilers optimize our code?

Hi, I ran into this question when i was answering another guys question. How do compilers optimize the code? Can keywords like const, ... help? Beside the fact with volatiles and inline functions and how to optimize the code all by your self! ...

strcpy() and arrays of strings

I need to store the input from a user into an array of strings. #include <stdlib.h> #include <stdio.h> #include <string.h> char *history[10] = {0}; int main (void) { char input[256]; input = "input"; strcpy(history[0], input); return (EXIT_SUCCESS); } Running it on the terminal I get a Segmentation Fault and in ...

understanding shared libraries using gcc

I am trying to understand the following behavior of shared libraries in C Machine One $ cat one.c #include<stdio.h> int main() { printf ("%d", 45); } $ gcc one.c -o one -O3 $ ldd one linux-gate.so.1 => (0x00331000) libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x00bc2000) /lib/ld-linux.so.2 (0x006dc000) $ cat two.c ...

Platform Invoke, bool, and string

Hi. suppose a dll contains the following functions extern "C" __declspec(dllexport) void f(bool x) { //do something } extern "C" __declspec(dllexport) const char* g() { //do something else } My first naive approach to use these functions from C# was as follows: [DllImport("MyDll.dll")] internal static extern void f(bool x); [Dl...

What do the terms platform and framework refer to?

Hi, I ran into this question many times ago and have seen the terms again and didn't know their real concept in computer engineering. What do platform and framework refer to? I see many terms like platform-independent and development platforms, and also same for frameworks, but i can't quietly understand them. Do they refer to librarie...

Pointer in C, don't understand how they got this result

here is code snippet void F (int a, int *b) { a = 7 ; *b = a ; b = &a ; *b = 4 ; printf("%d, %d\n", a, *b) ; } int main() { int m = 3, n = 5; F(m, &n) ; printf("%d, %d\n", m, n) ; return 0; } answer 4 4 3 7 I see how 4 4 was computed, I don't get how they got 3 7 (I do understand how 3 is computed, it is not changed sinc...

error: invalid operands to binary % (have 'double' and 'double')

I have a program I am writing that lists 100,000 prime numbers. It works fine for 10 numbers, but after so many numbers they turn into negative values. I changed the ints to long ints and that did not change anything, then I changed them to doubles and I get the error listed in the title. What should my variable be? Keep in mind I am...

How can I configure Visual Studio 2008 Express Edition to c89/c90/c99?

I'm getting lots of compiler errors due to standards' issues. ...

C Concatenate int

I will be the first to admit, I'm a C# guy 100% and C isn't for me. However I have problem. I need to concatenate 7 with HashUrl(HashInt) and then with HashInt Any help would be greatly appreciated. int main(int argc) { unsigned int HashInt; HashInt = HashURL(argc); // I need to return 7 + CheckHash(HashInt) + HashInt but not ADDING, bu...