c

C maximum size in main

Possible Duplicate: C programming, why does this large array declaration produce a segmentation fault? This is my first time here so sorry if I break some rules or if this has been answered before. I recently made a C program in which I had a matrix of char buff[NR][1024*1024]; I needed NR = 128. So the program would alocat...

Sparc Procedure Call Conventions

Hi all, I would like to do some "inline" assemly programming in Sparc and I am wondering how I can do that with register passing. Best to explain my issue with a small example int main() { int a = 5; int b = 6; int res; asm_addition(a,b); printf("Result: %d\n", res); return(0); } // My assembler addition .global...

memset causes exception when pinvoke

I am using pinvoke to call functions from sslscan tool based on openssl; I checked by hit and trial that where exception is occuring is due to memset. It runs fine when i run it natively in VS.but using pinvoke causes this exception in c#.Its System.AccessViolation Exception. These are the declarations: struct sslCheckOptions options;...

Why does curl require both .lib and .dll to work?

I just downloaded curl and managed to build a programe with it. What I don't understand is why it requires both curllib.lib and curllib.dll ? In my opinion either curllib.lib or curllib.dll should be enough, why both? Also I've searched through the source but doesn't find anywhere it uses dlopen to load curllib.dll, so why is curllib....

fibonacci! if goes false all time

I made a program to find if a number belongs to fibonacci series or not and if it does whats its position.Whenever i type a number the if Condition goes wrong. #include<stdio.h> #include<conio.h> #include<math.h> void main(void) { int i,x=1,y=1,z,num; clrscr(); printf("Enter a number to find in fibonacci series:"); scanf...

Why is %hd necessary in scanf?

I created a very simple progam whith a menu, that take a value, then memorize it into the local variable value, and finally with the second option the progam prints the value. my question is: Why does the program work only if I add an "h" to the scanf parameter? In other words: what kind of relation there is between scanf() and my loca...

Why is programming with objects not considered procedural?

Even though OOP uses objects and data encapsulation, the code still writes out like a procedure. So what makes OOP loose the procedural label? Is it just because it is considered "high-level"? Thank You. ...

Writing a Macro for this: (Objective-C)

Hi, I have a method like this: - (CGPoint) _convertCGPointCT2UIKit:(CGPoint)ctPoint{ CGPoint uikitPoint = CGPointMake(ctPoint.x + INITIAL_HORIZ_OFFSET, self.bounds.size.height - ctPoint.y - INITIAL_VERT_OFFSET); return uikitPoint; } Is there any way I can make this a macro? I tried this but I get errors like "; expected b...

Is there a multiple character version of strchr() in the standard C libraries?

In c if I wanted to search a string for a particular character I can just do the following char *p; p = (char *)strchr(buffer,'('); if(p){ .... but what if I want to search for more than one character (or a character range) for example "any digit". I know I could do something like char *p=0; char *i; for(i=buffer;*i!='\0';i++){ ...

C - going from ncurses ui to external program and back

I'm making a program that displays some info in ncurses, and then opens vim (using system) to allow the user to edit a file. After vim is exited, though, the ncurses screen won't redraw. refresh and wrefresh don't do anything, resulting in the complete trashing of my beautiful menu. So, I get sent back to the command line. The menu i...

How can adding a function call cause other symbols to become undefined when linking?

Hey Guys, I'm hoping someone will be able to help troubleshoot what I think is a linker script issue. I'm encountering a strange problem after adding a call to a new function. Without the function call, my object files link correctly, however, with the new function call added, I get an undefined reference to a symbol from another object...

What datatype should I bind as query parameter to use with NUMBER(15) column in Oracle ODBC?

I have just been bitten by issue described in SO question Binding int64 (SQL_BIGINT) as query parameter causes error during execution in Oracle 10g ODBC. I'm porting a C/C++ application using ODBC 2 from SQL Server to Oracle. For numeric fields exceeding NUMBER(9) it uses __int64 datatype which is bound to queries as SQL_C_SBIGINT. Appa...

Can I read a dynamical length variable using fread without pointers?

I am using the cstdio (stdio.h) to read and write data from binary files. I have to use this library due to legacy code and it must be cross-platform compatible with Windows and Linux. I have a FILE* basefile_ which I use to read in the variables configLabelLength and configLabel, where configLabelLength tells me how much memory to alloc...

Should you always use 'int' for numbers in C, even if they are non-negative?

I always use unsigned int for values that should never be negative. But today I noticed this situation in my code: void CreateRequestHeader( unsigned bitsAvailable, unsigned mandatoryDataSize, unsigned optionalDataSize ) { If ( bitsAvailable – mandatoryDataSize >= optionalDataSize ) { // Optional data fits, so add it to...

Ensure compiler always use SSE sqrt instruction

I'm trying to get GCC (or clang) to consistently use the SSE instruction for sqrt instead of the math library function for a computationally intensive scientific application. I've tried a variety of GCCs on various 32 and 64 bit OS X and Linux systems. I'm making sure to enable sse with -mfpmath=sse (and -march=core2 to satisfy GCCs requ...

Embedding linker dependencies in an object file?

Let's say I have a source file, say helper.c, which gets compiled into an object library (helper.a). Now, this uses functionality from many system libraries, so currently when I want to link helper.a into an executable, I end up having to list all the dependencies: gcc main.c helper.a -o my_app -lrt -lpthreads ... What's the common ap...

"Error - symbol 'tr' has multiple definitions."

I'm trying to compile a code for bumper switches in my robot and i get this error:" Error - symbol 'tr' has multiple definitions." What does this mean? I'm painfully new to this... ...

Struct initialisation through macro overuse

Hi, I've got some structs to initialise, which would be tedious to do manually. I'd like to create a macro that will help me with it... but I'm not sure C preprocessor is good enough for this. I've got structs which represent menus. They consist of function pointers only: typedef uint8_t (*button_handler) (uint8_t); typedef void (*peda...

Please explain the output for this code

int a=5; printf("%d %d %d\n",a++,a++,++a); Output on Gcc : 7 6 8 Can someone please explain the answer. I apologize if this question has been repeated but i wasn't able to find it. Thanks!! ...

Why isn't regular expressions part of ISO C99

Everyone knows how awesome C language is and how much it sucks in text processing tasks. Given these facts. Regex definitely must be part of ISO C. But it isn't. I don't understand why? Are there people who think its not essential? ...