question
stringlengths
24
425
answer
stringlengths
5
405
i know it sounds crazy but, i just want to ask if is a compiler support multi programming language? like Delphi could also support C/C++/C# etc? if there is, please let me know. or how?
The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Java, and Ada http://gcc.gnu.org/
I have a function that is doing memcpy, but it's taking up an enormous amount of cycles. Is there a faster alternative/approach than using memcpy to move a piece of memory?
memcpyis likely to be the fastest way you can copy bytes around in memory. If you need something faster - try figuring out a way ofnotcopying things around, e.g. swap pointers only, not the data itself.
i am working on C source to translate to delphi but i was stuck on reading files on ftell() function, can you help me find the equivalent function in delphi?
If you have an object of typeFile, then you may use theFilePos()function,described here.
Is there any C\C++ Cross-platform library for sharing data between app's?
Obviously the answer to your question is.. Yes there are many cross platform libs for sharing data between applications. For example Boost hasBoost Serialization, for data storage and reading, andBoost Interprocess, for in-memory data sharing.
I'm trying to make a script that can generate a kind of chat client in cygwin on windows but I don't have a clue how to start, I saw something like gtk+ but how do I get that inside of cygwin, and what have I to do after that?
Cygwin has anassortmentof gtk packages. After that you need to read some documentation and learn how to use the toolkit to make your program.Hereis a tutorial to get you started.
Suppose I have One set of numbers i.e {1, 6, 3, 5, 7, 9} I want to Generate Random number from this set of number only i.e. a Generated number should be random and should be from these number({1, 6, 3, 5, 7, 9}) only. standard C/C++ function will also do...
arc4random%(set count) = a random index.
Is there a portable C library to access .zip archives? "gzip" or "zlib" (the closest I could find) only handle compressed data, I need to be able to list the files inside the archive, and access each one individually, and if they're compressed using the 'deflate' method, I can use zlib on it.
Minizip, maybe? http://www.winimage.com/zLibDll/minizip.html
I was wondering if you knew of a robust implementation of a hashtable in C. I'm looking for something other than ghashtable in glib. Thanks.
I've heard good things about theGLib Hash Table.
Is there a portable C library to access .zip archives? "gzip" or "zlib" (the closest I could find) only handle compressed data, I need to be able to list the files inside the archive, and access each one individually, and if they're compressed using the 'deflate' method, I can use zlib on it.
Minizip, maybe? http://www.winimage.com/zLibDll/minizip.html
I was wondering if you knew of a robust implementation of a hashtable in C. I'm looking for something other than ghashtable in glib. Thanks.
I've heard good things about theGLib Hash Table.
does ansi c allows serial communication on rs232 null modem? if yes then any one give me example? thanx in advance
Ansi C has nothing to do with serial communications. ANSI C is a formal description of the C language, it doesn't define libraries. Communicating with an RS-232 modem is possible with C language, but it will be completely different in different platforms (Windows, Linux, embedded processors).
I need to know if there is an iPhone C compiler that can be installed on the iPhone. Then I would like to know what parameter I would put in thesystem("compile Foo")function. Thanks for the help in advanced.
Unfortunately for your purposes, an app store app is not permitted to launch another process, which would mean that you couldn't use another compiler even if you could install one on the phone.
The way being suppose the data is 123 134 2312 32131 2131231 211212 It should take them as different numbers and store them in an integer array .
You can usefscanfwith%dformat specifier to read successive integer values from a text file.
Does Windows provide some sort of evented API so I can run some code whenever a drive (say a usb stick) is attached?Similar to howReadDirectoryChangesWis for events on the filesystem?I am not interested only in hardware changes, a user can also mount a volume, a ftp drive or similar.
I am not sure of the API, but you can handle theWM_DEVICECHANGEmessage.
MY scenario is... I have 6,000 datas in Excel Sheet.. I try to import to Access Database.It enters the Database like this.. UNit Price 34512.00 Vat 4.00 BUt when i Retrieve to DataGridColumn it Shows vat Rate as 4(whole number).I accept zeros has no values..But I need that to be displayed in Grid as 4.0 . How to achieve this
Use a format string, here is some referenceStandard Numeric Format Stings
I was wondering how I can show description text. By this I mean, for example if you hover over the Start button a small description will appear saying "Start". How are these invoked? Thanks
You are looking forTooltip Controls
This question already has answers here:Closed13 years ago. Possible Duplicate:How do I call unmanaged C/C++ code from a C# ASP.NET webpage is there a way to link the two?
P/Invokeis the approach you want
Is there a way of converting a char into a string in C? I'm trying to do so like this: ``` char *array; array[0] = '1'; int x = atoi(array); printf("%d",x); ```
``` char c = '1'; int x = c - '0'; printf("%d",x); ```
I was wondering how I can show description text. By this I mean, for example if you hover over the Start button a small description will appear saying "Start". How are these invoked? Thanks
You are looking forTooltip Controls
This question already has answers here:Closed13 years ago. Possible Duplicate:How do I call unmanaged C/C++ code from a C# ASP.NET webpage is there a way to link the two?
P/Invokeis the approach you want
Is there a way of converting a char into a string in C? I'm trying to do so like this: ``` char *array; array[0] = '1'; int x = atoi(array); printf("%d",x); ```
``` char c = '1'; int x = c - '0'; printf("%d",x); ```
Content ofX.c: ``` int i; main () { fun (); } ``` Content ofY.c: ``` int i; fun () { } ``` Why does these two files compile with no error ? (using GCC) But if i useint i = 10;it prints a multiple definition error.
You may be interested in this question and the answers. Keywords: "tentative definition". Tentative definitions in C99 and linking
I need to get last four bytes out of a double variable .The platform is Arm and compiler is RVCT.Programming language used is C.What is the safest way. Thanks
``` int lastFour = *(((char*) &origDouble) + sizeof(double) - 4) ```
I have a set of characters, minimum hundreds of characters. How could i get the position of a particular character in that list efficiently.
If you set of characters is sorted, you can usebsearch(). If not, you're pretty much out of luck - you'll have to use a simple scan, likestrchr().
I am programming in C, using the Windows API, and would like to know how I could drawseparators. I would appreciate a code example. Edit: Here's an illustration. (source:microsoft.com)
Use a static control/window with theSS_ETCHEDHORZstyle (This is what explorer does and should give you the most accurate rendering when it comes to Visual Styles)
I need to execute a file when I only know the descriptor. It is also possible that there are no links to the file so finding out the name somehow is not an option. All the execve(), execvp(), etc functions take a file name. dlopen() also takes a name. Ugly solutions (like reading the file and calling some function pointer) are OK.
Usefexecve. PS: reading the file and calling some function pointer is definitelynotOK. :)
can somebody please explain, I have a program on C, can I convert it to assembly? if yes, how?
If you use gcc you can dogcc -O2 -S -c foo.caccording tothispage to get the output assembly in a human readable form.
I am programming in C, using the Windows API, and would like to know how I could drawseparators. I would appreciate a code example. Edit: Here's an illustration. (source:microsoft.com)
Use a static control/window with theSS_ETCHEDHORZstyle (This is what explorer does and should give you the most accurate rendering when it comes to Visual Styles)
I need to execute a file when I only know the descriptor. It is also possible that there are no links to the file so finding out the name somehow is not an option. All the execve(), execvp(), etc functions take a file name. dlopen() also takes a name. Ugly solutions (like reading the file and calling some function pointer) are OK.
Usefexecve. PS: reading the file and calling some function pointer is definitelynotOK. :)
On Linux, how can I make sure that my program is the only one accessing a file?
I am not sure, but I believe you are referring tofile locking. Seethisandthisand don't forgetthis. Your display name is gcc but if you are doing this on windows, seeLockFileEx.
Please excuse my C newbiness. Consider the following C procedure: ``` int doSomething() { char *numbers="123456"; ... } ``` Before this procedure exits should I be releasing the 'numbers' pointer?
No, you didn'tmallocit. Why should you release it? Often, the string is placed in a read only section of the executable.
How do I get the UTC time in milliseconds under the Windows platform? I am using the standard library which give me UTC time in seconds. I want to get the time in milliseconds. Is there a reference of another library which give me the accurate UTC time in milliseconds?
UseGetSystemTimeAPI function, or perhapsGetSystemTimeAsFileTimeif you want a single number.
I have seen some performance figures are represented by MCPS unit, especially in some dsp codec performance. Can anybody clarify me this? /kanu__
It essentially means that some trivial operation can be done N million times each second. For example, the processor could perform up to N million arithmetic operations of certain kind each second and not more.
I have calledgetpeernameon my connected socket and now have an IPv6 address of the connected peer. How do I tell whether my peer's IP address is localhost? Edit: To clarify, I mean specificallylocalhost, as in the loopback IP address.
In IPv6, the loopback address is::1. At the binary level, that is 127 0's followed by a single 1.
Quick and easy C question:char* foo How can I test iffoohasn't still been assigned a value? Thanks.
You can't. Instead, initialize it withNULLand check whether it isNULL: ``` char *foo = NULL; ... if(!foo) { /* shorter way of saying if(foo == NULL) */ ```
in Java I think it is possible to cruise through jar files like they were not compressed. Is there some similar (and portable) thing in C/C++ ? I would like to import binary data into memory from a large (zipped or similar) file without decompressing to disk first and afterwards writing to disk in a compressed way. Maybe some trick with shell pipes and the zip utility?
I think you want zlib:http://www.zlib.net/
Does the Windows native API support timers? I am aware that POSIX implementations on Windows support timers, but I am interested in Windows SDK APIs.
Yes there are timers in Win32 API. More details you can check here :Timers In particular you need to check SetTimerKillTimerTimerProcWM_TIMER
I have created a control and the mosemove for that control makes it change color, but I want to change it back to default when my mouse moves out of that control. I would have thought WM_MOUSELEAVE would do it but it didn't. Thanks
That would be the correct message. Are you callingTrackMouseEvent?
To read anintusing scanf we use: ``` scanf("%d", &i); ``` What ifiis alongnotint?? Note: when using%dwithlongit gives me an irritating warning..
Just use ``` long l; scanf("%ld", &l); ``` it gives me an irritating warning.. That warning is quite right. This is begging for stack corruption.
How do i add SOCKS support to my application? and where can i get the libs? any help appreciated thanks
You could tryBoost.Asiolibrary. It containsan examplewith SOCKS4 protocol implementation.
I am making an iPhone app. I have a code that is in C. The C code contains a lot of pointers and global variables. I want to use this C code in my objective-c project. Can anybody please help me with this?
Objective-C is a perfect superset of C. Just add the file to your Xcode project like you normally would.
Is there a way to get pre-processedC/Objective-C code? I have some files I acquired and would like to see the code produced by some #defines.
From within Xcode: Xcode 3: Select the file, thenBuild β†’ Preprocess.Xcode 4: Select the file, thenProduct β†’ Generate Output β†’ Generate Preprocessed File.
i have time of the day in seconds and i have to find the utc time since 1970, is there any api which can directly convert this time to utc time, i m using ansi c , and working on windows platform platform independent api will be preferred thanx in advance.
You can fill in atm structwith the time of day you have (you'd have to convert it into seconds/minutes/hours) and the date. Then convert it withmktime()intime.h.
I am making an iPhone app. I have a code that is in C. The C code contains a lot of pointers and global variables. I want to use this C code in my objective-c project. Can anybody please help me with this?
Objective-C is a perfect superset of C. Just add the file to your Xcode project like you normally would.
Is there a way to get pre-processedC/Objective-C code? I have some files I acquired and would like to see the code produced by some #defines.
From within Xcode: Xcode 3: Select the file, thenBuild β†’ Preprocess.Xcode 4: Select the file, thenProduct β†’ Generate Output β†’ Generate Preprocessed File.
i have time of the day in seconds and i have to find the utc time since 1970, is there any api which can directly convert this time to utc time, i m using ansi c , and working on windows platform platform independent api will be preferred thanx in advance.
You can fill in atm structwith the time of day you have (you'd have to convert it into seconds/minutes/hours) and the date. Then convert it withmktime()intime.h.
i have time of the day in seconds and i have to find the utc time since 1970, is there any api which can directly convert this time to utc time, i m using ansi c , and working on windows platform platform independent api will be preferred thanx in advance.
You can fill in atm structwith the time of day you have (you'd have to convert it into seconds/minutes/hours) and the date. Then convert it withmktime()intime.h.
I want to know aboutconstinternals in C and C++ . How does the compiler impose"constantness"?
In generalconstis 100% compiler. When you declare something const,the compilerplaces restrictions on what it will let you write. It won't let you assign to const scalar, assign through a const reference or or pointer, or invoke a non-const function of const object. There is no guarantee that the compiler will arrange any sort of runtime protection.
Are there examples of recursion using only heap area?
In C, function call-based recursion always uses the stack, almost by definition. If you are willing to convert your recursion to iteration, then it is possible to use only heap space, but that isn't really recursion. You would do so by implementing a stack in the heap. Certain problems can usetail recursion, which repeatedly overwrites the same area of the stack.
i want to prepare a byte buffer as a upd packet i want to fill each value in reverse order how can i do so in ansi c i have to do this on windows system,
Assuming you are doing this so it will work on any receiving system: Usehtonl()on each byte in your buffer when sending andntohl()on each received byte.
Pay attentions that there is a space in it. Which function can I use?
You can use ``` if (!strncmp("GET ", str, 4) { ... } else if (!strncmp("POST ", str, 5)) { ... } else { ... } ```
I have heard of WINE but I don't like it because it's slow on the computers I have tested and almost always crashes. It also has some unpleasant looking gui.I am wondering if there is a "win32" library in c/c++ for linux that producesnative linux codeso that if I have my source code for windows, I can just recompile and produce a working linux application. Is this possible?
You're looking forWinelib.
Is there anyway to do "insmod" and "rmmod" from C/C++ code? Other than running system(...), is there a Kernel API that will allow me to do this?
Have you looked at themodule-init-toolssource?
Pay attentions that there is a space in it. Which function can I use?
You can use ``` if (!strncmp("GET ", str, 4) { ... } else if (!strncmp("POST ", str, 5)) { ... } else { ... } ```
I have heard of WINE but I don't like it because it's slow on the computers I have tested and almost always crashes. It also has some unpleasant looking gui.I am wondering if there is a "win32" library in c/c++ for linux that producesnative linux codeso that if I have my source code for windows, I can just recompile and produce a working linux application. Is this possible?
You're looking forWinelib.
Can somebody please explain what does this warning mean:undefined reference to 'WinMain@16'?
Googlehaslotsofreferencestothat particular error. You need to provide aWinMainfunction, depending on what type of project you are building (console or Windows app).
I'd like to know if a fd has data available for reading. I have triedioctlwithFIONREADbut that results in a "Operation not supported error". Any ideas?
You can useselect(), with a zero (notNULL) timeout.
Can somebody please explain what does this warning mean:undefined reference to 'WinMain@16'?
Googlehaslotsofreferencestothat particular error. You need to provide aWinMainfunction, depending on what type of project you are building (console or Windows app).
I'd like to know if a fd has data available for reading. I have triedioctlwithFIONREADbut that results in a "Operation not supported error". Any ideas?
You can useselect(), with a zero (notNULL) timeout.
I'm in the process of documenting some firmware but I'm unsure what the standard is (if there is one) for representing static variable declaration in flowcharts
In the 'classic' flowchart it would just be the rectangle.
What does theexternkeyword mean? I've seen that in front of an function declaration like ``` extern void DoFoo ... ```
externgives a nameexternal linkage. This means that the object or function is accessible through this name from other translation units in the program. For functions, this is the default linkage in any case so its usage (in this context) is usually redundant.
What's the "DNS_BLOCK_ASSERTIONS" (C compiler flag)?
The NS_BLOCK_ASSERTIONS macro (no "D") suppresses the checks performed by NSAssert. You supply it to the compiler using-DNS_BLOCK_ASSERTIONS(see the comments for an explanation of the "D").
And, if it does, how do you use one? (syntax) Also, why does or why doesn't C support lambda expressions?
No, C has no support for lambda expressions. If you're willing to use C++, Boost has a library that emulates lambdas. Also, C++0x will have built-in support for lambda expressions. There wasn't a huge demand for lambda expression support in C at the time, so the language didn't support it.
I'm in the process of documenting some firmware but I'm unsure what the standard is (if there is one) for representing static variable declaration in flowcharts
In the 'classic' flowchart it would just be the rectangle.
What does theexternkeyword mean? I've seen that in front of an function declaration like ``` extern void DoFoo ... ```
externgives a nameexternal linkage. This means that the object or function is accessible through this name from other translation units in the program. For functions, this is the default linkage in any case so its usage (in this context) is usually redundant.
What's the "DNS_BLOCK_ASSERTIONS" (C compiler flag)?
The NS_BLOCK_ASSERTIONS macro (no "D") suppresses the checks performed by NSAssert. You supply it to the compiler using-DNS_BLOCK_ASSERTIONS(see the comments for an explanation of the "D").
And, if it does, how do you use one? (syntax) Also, why does or why doesn't C support lambda expressions?
No, C has no support for lambda expressions. If you're willing to use C++, Boost has a library that emulates lambdas. Also, C++0x will have built-in support for lambda expressions. There wasn't a huge demand for lambda expression support in C at the time, so the language didn't support it.
Often I see a function declared like this: ``` void Feeder(char *buff, ...) ``` what does "..." mean?
It allows a variable number of arguments of unspecified type (likeprintfdoes). You have to access the arguments with theva_start,va_argandva_endfunctions. Seehttp://publications.gbdirect.co.uk/c_book/chapter9/stdarg.htmlorWhere in the C standard variadic functions are described?for more information
I am using C as the programming language. How to ignore the sign when using float/signed int variables? For example if float/signed int f = -40 or +40 The result should be same after a mathematical operation like a+b*f
Useabsfor ints orfabsfor floats. ``` a+b*abs(f) ``` EDIT:It's not clear wether you want -40 to be treated as 40 or vice versa, if you for some reason wan't the latter: ``` a+b*-abs(f) ```
In some library I'm using (written in C) its ``` StorePGM(image, width, height, filename) char *image; int width, height; char *filename; { // something something } ``` All functions are defined this way. I never seen such function definitions in my life. They seem to be valid to MSVC but when I compile it as C++ it gives errors. What is it? some kind of old version C?
Yes. K&R, pre-standard C. Avoid using it.
Often I see a function declared like this: ``` void Feeder(char *buff, ...) ``` what does "..." mean?
It allows a variable number of arguments of unspecified type (likeprintfdoes). You have to access the arguments with theva_start,va_argandva_endfunctions. Seehttp://publications.gbdirect.co.uk/c_book/chapter9/stdarg.htmlorWhere in the C standard variadic functions are described?for more information
Many places I saw that we can use startupinfoex structure in CreateProcess function. But when I checked the signature is only allowing startupinfo structure. Can anybody please give a snippet how startupinfoex can be used with createprocess function. Thanks in advance....
You need to cast theSTARTUPINFOEX*to aSTARTUPINFO*. Be sure to pass theEXTENDED_STARTUPINFO_PRESENTflag todwCreationFlagsand set theStartupInfo.cbmember tosizeof(STARTUPINFOEX).
Is there a way to concatenate keywords in a macro and getC to behave in a more dynamic fashion as in: ``` #define macro(fun,ction,var,iable) function(variable) ``` I know this kind of thing exists in other languages.
You can use ## to concatinate names in macros fun##ction ...
I checked out the microsoft documents. it shows how to create a static library upon creation of the project. but not necessarily on how to convert a previously made project, into a static library. So my question is, where do I go to turn my previously made project, into a static lib. so I can include it in my other projects
Project | Properties -> Configuration Properties -> General -> Configuration Type (Static Library).
I'm looking for the C grammar in GCC source code, more specifically for the grammar in the yacc/bison form.
Found the C grammar in Yacc specification in the GCC version 3.3 in the file "c-parse.y"
I'm looking for the C grammar in GCC source code, more specifically for the grammar in the yacc/bison form.
Found the C grammar in Yacc specification in the GCC version 3.3 in the file "c-parse.y"
I need a powerful HTML parser and manipulator for Objective-C/C, like HTML Agility Pack. Can anyone tell me some optimal solution? One solution is libxml2, but it seams is not the best. Thanks in advance!
On MacOS X,NSXMLDocumentis a good solution (but you want iPhone). Two packages that you should look at are:TouchXMLandKissXML. See alsoiPhone Development - XMLParser vs. libxml2 vs. TouchXML.
In the many search functions of C (bsearch comes to mind) if a result is found, a pointer to the spot in the array is returned. How can I convert this pointer to the index in the array that was searched (using pointer arithmetic, i assume).
``` ptrdiff_t index = pointer_found - array_name; ```
How do I execute another program from within a C program in Windows 32 - in a similar way as Perl'ssystem()function or Python's sub-process module - such asDEL,REG, or other cmd.exe programs?
C does have asystemfunction in its standard library, see e.g. thewikipediaentry about it.
This is a simple problem, but I can't see it: ``` char *s = "f 8.649292" ; double d ; sscanf( s, "f %f", &d ) ; printf( "d is %f\n", d ) ; ``` Why isdnot containing the double value8.649292?
Oh wait, nevermind. d needs to be afloat. And to make it work you could use%lffor a double ``` char *s = "f 8.649292 " ; double d ; sscanf( s, "f %lf", &d ) ; printf( "d is %lf\n", d ) ; ```
i have a small program that uses 32bit object file, and i wish to run it under dos operating system. now, after searching i foundDJGPP.is there a way to use DJGPP to compile my program to 16Bit dos executable format?thanks in advance
Take a look atthisrelated Stack Overflow question. It might help.
This question already has answers here:Closed13 years ago. Possible Duplicate:Uses for multiple levels of pointer dereferences? I have used functions with doubly dereferenced pointers (**var) to return values. However, I was recently asked a question to figure out a use-case where a triple dereferencing (***var) may be needed. I couldn't think of any practical scenario. Does anyone have any experience here?
Three dimensional arrays.
In gcc I can do compile-time warnings like this: ``` #if !defined(_SOME_FEATURE_) #warning _SOME_FEATURE_ not defined-- be careful! #endif ``` But in Visual Studio this doesn't work. Is there an alternative syntax for #warning?
About the closest equivalent would be#pragma message, or possibly#error(the latter stops compilation, the former just prints out the specified error message).
How to hide the mouse pointer on the window screen of GDI, kindly give me some hints.
TryShowCursor(false); Sources: http://msdn.microsoft.com/en-us/library/ms648396.aspx http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.gdi/2004-08/0045.html
Can anybody suggest how to convert actionscript to c code?
There is no automatic way of doing that. The languages offer very different sets of features. You'll have to do it manually, preferably in a top-down manner. This means that when making the C implementation, write the most abstract functionality first, gradually going into the details.
The elements of the array are arranged in non-decreasing order. I need to search the array for a given element in the least possible time.
Since the array is sorted you can make use ofBinary Search. Alinearsearch will takeO(n)time because it does not make use of the sorted property. But abinarysearch will takeO(log n)time.
i have a string of the format "ABCDEFG,12:34:56:78:90:11". i want to separate these two values that are separated by commas into two different strings. how do i do that in gcc using c language.
One possibility is something like this: ``` char first[20], second[20]; scanf("%19[^,], %19[^\n]", first, second); ```
i have a small program that uses 32bit object file, and i wish to run it under dos operating system. now, after searching i foundDJGPP.is there a way to use DJGPP to compile my program to 16Bit dos executable format?thanks in advance
Take a look atthisrelated Stack Overflow question. It might help.
This question already has answers here:Closed13 years ago. Possible Duplicate:Uses for multiple levels of pointer dereferences? I have used functions with doubly dereferenced pointers (**var) to return values. However, I was recently asked a question to figure out a use-case where a triple dereferencing (***var) may be needed. I couldn't think of any practical scenario. Does anyone have any experience here?
Three dimensional arrays.
In gcc I can do compile-time warnings like this: ``` #if !defined(_SOME_FEATURE_) #warning _SOME_FEATURE_ not defined-- be careful! #endif ``` But in Visual Studio this doesn't work. Is there an alternative syntax for #warning?
About the closest equivalent would be#pragma message, or possibly#error(the latter stops compilation, the former just prints out the specified error message).
suppose there is a string of characters in an array of d[20] . How to convert to a string d so that i can use it in string functions like strcmp..
It must be null-terminated. That's the only requirement. I presume you know how to do that.
I have some C code that parses a file and generates another file of processed data. I now need to post these files to a website on a web server. I guess there is a way to do a HTTP POST but I have never done this in c (using GCC on Ubuntu). Does anyone know how to do this? I need a starting point as I have no clue of doing this in C. I also need to be able to authenticate with the website.
libcurlis probably a good place to start.
I'm developing C extensions from python and I obtain some segfaults (inevitable during the development...). I'm searching for a way to display at which line of code the segfault happens (an idea is like tracing every single line of code), how can I do that?
If you are on linux, run python under gdb ``` gdb python (gdb) run /path/to/script.py ## wait for segfault ## (gdb) backtrace ## stack trace of the c code ```
I am looking for a SOAP Library for C. I know there is gSOAP. What other options do I have?
Take a look at thisblogentry. I know it's C++, but I have had good results with Apache's AXIS. If you can use a C++ compiler, you can wrap around a C library to your generated classes.
How can we implement the modulo operator as a function in C without using the operator?
Do an integer division followed by a multiplication, and subtract. ``` #include <stdio.h> int main() { int c=8, m=3, result=c-(c/m*m); printf("%d\n", result); } ```
I want to know how to announce int to make sure it's 4 bytes or short in 2 bytes no matter on what platform. Does C99 have rules about this?
C99 doesn't say much about this, but you can check whethersizeof(int) == 4, or you can use fixed size types like uint32_t (32 bits unsigned integer). They are defined instdint.h
Is there a way to know whether a variable is defined, by looking at the executable. Lets say I declare ``` int i; ``` in the main function. By compiling and linking I get an executable my_program.exe. Now, by looking inside my_program.exe, can I say if it has aninteger variablei?
Not unless you compile with debugging enabled.
Usually it will ignore C files that are not documented, but I'd like to test the Callgraph feature for example, do you know a way around this without changing the C files?
Set the variableEXTRACT_ALL = YESin your Doxyfile.
Is it possible to use C/C++ code in Android? And how easy is it?
Its possible. Use the Native Development Kit (NDK). Seeherefor more discussion and links. How easy is it? I don't know, I've never tried!
Whenever any question is asked, and a reference text is needed, I never seeMSDN C++ Language Referencebeing referred. I was browsing through it and I personally feel that it is extremely well written. Is there some specific reason it is not used as often as a standard? Is it because it contains some VC++ specific features?
I believe it's because those of us referencing a reference reference the actual standard itself.