c

2D-float array values scan

Hi, I wrote a code by using C language as follows: main() { float x[10][10]; int i,j; clrscr(); scanf("%d%d",&i,&j); for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%f",&x[i][j]); ...... } When i run this program, there is an ABNORMAL TERMINATION with the error like 'FLOATING POINT CONVERSIONS NOT LINKED'...

Curses getting arrow keys

In trying to get input from the arrow keys via curses (ncurses) it won't catch as KEY_UP etc. I used the keypad function with a true argument but getch still returns an escaped sequence. How do I sift through the values returned by getch() and grab the arrow keys specifically? ...

Is Template Metaprogramming faster than the equivalent C code ?

Is Template Metaprogramming faster than the equivalent C code ? ( I'm talking about the runtime performance) :) ...

Problem with lseek

Hi, I have the following code in C long from = atol(buffer); printf("From: %ld\n", from); int file_fd = open(fullPath, O_RDONLY); if (file_fd == -1) error("Error opening file"); if (from > -1) { int a = lseek(file_fd, from, SEEK_SET); if (a == -1) error("Error in lseek"); } The lseek operation is returning Error in ...

How to send POST request to some website using winapi?

I'd like to send HTTP POST request to website and retrieve the resultant page using winapi. How can I do that? Thanks i advance. ...

Why weren't new (bit width specific) printf() format option strings adoped as part of C99?

While researching how to do cross-platform printf() format strings in C (that is, taking into account the number of bits I expect each integer argument to printf() should be) I ran across this section of the Wikipedia article on printf(). The article discusses non-standard options that can be passed to printf() format strings, such as (w...

creating a wrapper for strncpy to insert terminating null

Hello, I have decided to make a wrapper for strncpy as my source code requires me to do a lot of string copies. And I want to ensure that the string is terminated if the source is equal or greater than the destination. As this code will be used in production, so I just want to see if there are any potential dangers using this wrapper. ...

Are integers in C assumed to be handled by a hardware spec or handled in software?

Are integers in C assumed to be handled by a hardware spec or handled in software? By integer, I am referring to the primitive "int" The underlying idea being that if integers in C are not hardware dependent would it be a violation of standard to have gcc implement different integer handlers. This way you could have your traditional 32...

Is it possible to define a pointer to a character inside a text file?

Say we have opened a text file. Is it possible to define a pointer to a character in the file? If it is - will the following characters in the file appear in memory in the same order they appear in the file? The reason I ask: I need to process a text file. I read one line at a time and there are certain strings I want to keep. The buffe...

Is there a non-deprecated raster graphics framework for Mac OS X?

I am looking for a raster graphics framework for Mac OS X. Specifically, I want some kind of view that I can manipulate (at least conceptually) like a matrix of pixels. My program will generate the pixel data programmatically. QuickDraw fits that description nicely, but is deprecated. As far as I can tell, there is nothing equivalent in...

Where to put a re-usable code.

Hello, I have create a wrapper for the strncpy function. I will have to use this in my project which contains many headers and source files (about 20 all together). And this wrapper will be used in most of them. As the code is very short I am wondering where is the best way to implement this wrapper into my project? I am thinking th...

Memory barriers in userspace? (Linux, x86-64)

It is easy to set memory barriers on the kernel side: the macros mb, wmb, rmb, etc. are always in place thanks to the Linux kernel headers. How to accomplish this on the user side? ...

How to send optional arguments to another function/method?

I have an designated initializer with optional arguments (similar to the following code), and I want to create an autorelease method by calling it. Is there any way to do this? @interface MyObject : NSObject - (id)initWithArgs:(id)firstArg, ...; + (id)objectWithArgs:(id)firstArg, ...; @end @implementation MyObject - (id)initWithArgs...

invalid converstion from void* to char**

it has been a while since I messed with C code. I am getting the following error when compiling C code under ubuntu using gcc. command i am using to compile code is(if these errors are because of comiler I am using , please let me know how to make that go away): gcc -o runnable mycode.C error: invalid conversion from ‘void*’ to ‘...

Pointer to struct within the nested structs

Hello all, I'm trying to run the following code(in gcc 4.3 on fedora 11 i586 ): #include #include #include struct s_smallstruct{ int smallstruct; }; struct s_test2{ char * test2; struct s_smallstruct* smallstruct; }; struc...

The C programming language 2. ed. question

I'm reading the well known book "The C programming Language, 2nd edition" and there is one exercise that I'm stuck with. I can't figure out what exactly needs to be done, so I would like for someone to explain it to me. It's Exercise 5-17: Add a field-searching capability, so sorting may be done on fields within lines, each field sor...

char array vs. char pointer

Hey, When receiving data through a socket using recv, I've noticed that, with: char buffer[4]; memset(buffer, 0, 4); recv(socket, buffer, 4, 0); I receive mesgx�� "mesg" being what I sent, with some random characters appended. If I use char * method = (char *) malloc(4); memset(buffer, 0, 4); recv(socket, buffer, 4, 0); ...

Can I use C++ features while extending Python?

The Python manual says that you can create modules for Python in both C and C++. Can you take advantage of things like classes and templates when using C++? Wouldn't it create incompatibilities with the rest of the libraries and with the interpreter? ...

Naming scheme for typedefs

I'm working on a library that extensively used constructs like typedef struct foo_bar_s { ... } foo_bar_t; It's a bad idea to use the _t suffix, because it's a POSIX reserved namespace. The _s suffix for structs is also pretty useless. So I thought I can change it all to typedef struct foo_bar { ... } foo_bar; or if the str...

getc and getwc: How exactly do they read stdin?

Hello. I'm not exactly sure whether or not this is a silly question, but I guess I will find out soon enough. I'm having problems understanding exactly how getc and getwc work. It's not that I can't use them, but more like I don't know exactly what they do. int and getc return most characters if I `printf("%c") them, including multibyte...