c

Restricting symbols in a Linux static library

I'm looking for ways to restrict the number of C symbols exported to a Linux static library (archive). I'd like to limit these to only those symbols that are part of the official API for the library. I already use 'static' to declare most functions as static, but this restricts them to file scope. I'm looking for a way to restrict to ...

Beginner C Programmer needs help with pointers ( I think )

I'm a beginner programmer and I'm learning my first language, C. I'm learning mostly from Deitel and Deitel's C How to Program book, but also using example tasks and things from the university, however I am stuck on one. I have a very very basic understanding of pointers - adding & in front of a variable makes it print an address and ...

Pointer Arithmetic

Does anyone have any good articles or explanations (blogs, examples) for pointer arithmetic? Figure the audience is a bunch of Java programmers learning C and C++. ...

Memory footprint for C JNI increases even after freeing memory in code

I have created C shared object which is invoked using JNI, when I checked the memory footprint it keeps on increasing, and never reduces. But the memory is being being freed in C code, is there any way to overcome this behaviour of JNI. The memory footprint increases up to 2 GB and process gets killed. ...

Switching off optimization for a specific function in gcc 4.2.2

Is it possible to switch off optimization of a specific function? A friend of mine has the problem that the gcc optimization makes some (unknown to me) µ-controller-code not work. We know which functions it is, but we have no clue of the code itself so the easiest and safest way would probably be to just switch it off for the whole funct...

How does gedit edit and save a large file before the file is finished loading?

I wanted to edit just the first line of a 4 MB file. When I open files this large in gedit, it takes a minute or two to load the file but displays and allows you to edit the part that it has loaded so far. So I opened the file, quickly edited the first line, saved the file, and closed gedit all before it was even close to finishing loadi...

Replacements for the C preprocessor

I'm interested in using something other than the C preprocessor to preprocess my C and Objective-C source code. Are there good alternatives? An example would be something that allowed one to escape out into a python or perl snippet in the middle of C code, and where the snippet spit out C that is then compiled as normal. ...

What is the difference between exit() and abort()?

In C and C++, what is the difference between exit() and abort()? I am trying to end my program after an error (not an exception). ...

C/C++ Compiler for windows

I'm trying to port a Linux app to windows. Nothing huge, just a small command line utility. However, the last time I worked with C in Windows, it was a 'hello world' app in Visual Studio 6. I'm trying to avoid meeting a new IDE, so I'd like to use Netbeans' C/C++ plugin. I just need a compiler. Can anyone suggest a free 32-bit compi...

Port of Random generator from C to Java?

George Marsaglia has written an excellent random number generator that is extremely fast, simple, and has a much higher period than the Mersenne Twister. Here is the code with a description: good C random number generator I wanted to port the CMWC4096 code to Java, but it uses several unsigned datatypes so I am not sure how to do this ...

In C, why is the asterisk before the variable name, rather than after the type?

In my experience, everyone names variables like this: int *myVariable; Rather than like this: int* myVariable; Both are valid. It seems to me that the asterisk is a part of the type, not a part of the variable name. Can anyone explain this logic? ...

Is the sizeof(some pointer) always equal to four?

For example: sizeof(char*) returns 4. As does int*, long long*, everything that I've tried. Are there any exceptions to this? ...

Call mysql SOURCE command from a C program

I want to execute some mysql statements that are stored in a text file from my C program using the mysql.h library. My inclination was to do something like the following, but this doesn't work: mysql_query(conn, "source test.mysql"); This is because the SOURCE command is not a mysql statement in and of itself. Is there a way call ...

Why are c/c++ floating point types so oddly named?

C++ offers three floating point types: float, double, and long double. I infrequently use floating-point in my code, but when I do, I'm always caught out by warnings on innocuous lines like float PiForSquares = 4.0; The problem is that the literal 4.0 is a double, not a float - Which is irritating. For integer types, we have short in...

Splitting a string on AT&T IA-32 Linux Assembler (gas)

.section .data astring: .asciz "11010101" format: .asciz "%d\n" .section .text .globl _start _start: xorl %ecx, %ecx movb astring(%ecx,1), %al movzbl %al, %eax pushl %eax pushl $format call printf addl $8, %esp movl $1, %eax movl $0, %ebx int $0x80 Suppose I wanna break the .asciz string 1101011 and get it's first one. How do I...

XML Parser for C

Can you suggest some of the best XML Parser for C ? ...

Inadvertent use of = instead of ==

It seems that if (x=y) { .... } instead of if (x==y) { ... } is a root of many evils. Why don't all compilers mark it as error instead of a configurable warning? I'm interested in finding out cases where the construct if (x=y) is useful. ...

Best compiler warning level for C/C++ compilers?

What compiler warning level do you recommend for different C/C++ compilers? gcc and g++ will let you get away with a lot on the default level. I find the best warning level for me is '-Wall'. And I always try to remove fix the code for the warnings it generates. (Even the silly ones about using parenthesis for logical precedence rule...

Testing C code using the web

I have a number of C functions which implement mathematical formulae. To-date these have been tested for mathematical "soundness" by passing parameters through command line applications or compiling DLL's for applications like Excel. Is there an easy way of doing this testing over the web? Ideally something along the lines of: compi...

How to fetch HTML in C/C++

How to fetch HTML in C or C++? with Sockets. Can you give me a Example code pls? NOTE - I originally closed this, but reopened. To the poster - Please see: http://stackoverflow.com/questions/400688/fetch-web-page-in-c and http://stackoverflow.com/questions/389069/programmatically-reading-a-web-page#389074 ...