question
stringlengths
24
425
answer
stringlengths
5
405
I have the following in C: ``` long long int a; long long int b; long long int c; long long int d=a*b/c; ``` However, I want 'd' to be double. Is there a way I can multiply, divide long long int and get a double as an answer keeping up to 3 decimals as precision? Thanks
Cast (at least) one of thelong long ints todouble ``` double d = a * (double)b / c; ```
I have aGtkTreeViewhooked into aGtkListStore, but theGtkCellRendererTextthat's all on it's own in a column, a column which is set to expand. However the renderer is occupying a max width of 3 characters, just enough for the ellipsis... While, and after editing the text:
Did you create your window with GtkBuilder? It might bethis bugrearing its ugly head again...
I'm currently working on gcov and I need to pointers to study gcov. Perl scripts are being used to automate testing and I need to use gcov for test coverage. Apart from the gcov documentation what are the other things I should be aware of ? How do I proceed ?
Devel::Coverhas gcov support. ``` cd project_root perl Makefile.PL cover -test -gcov $BROWSER cover_db/coverage.html cover -delete ```
I have aGtkTreeViewhooked into aGtkListStore, but theGtkCellRendererTextthat's all on it's own in a column, a column which is set to expand. However the renderer is occupying a max width of 3 characters, just enough for the ellipsis... While, and after editing the text:
Did you create your window with GtkBuilder? It might bethis bugrearing its ugly head again...
I'm currently working on gcov and I need to pointers to study gcov. Perl scripts are being used to automate testing and I need to use gcov for test coverage. Apart from the gcov documentation what are the other things I should be aware of ? How do I proceed ?
Devel::Coverhas gcov support. ``` cd project_root perl Makefile.PL cover -test -gcov $BROWSER cover_db/coverage.html cover -delete ```
I have aGtkTreeViewhooked into aGtkListStore, but theGtkCellRendererTextthat's all on it's own in a column, a column which is set to expand. However the renderer is occupying a max width of 3 characters, just enough for the ellipsis... While, and after editing the text:
Did you create your window with GtkBuilder? It might bethis bugrearing its ugly head again...
I'm currently working on gcov and I need to pointers to study gcov. Perl scripts are being used to automate testing and I need to use gcov for test coverage. Apart from the gcov documentation what are the other things I should be aware of ? How do I proceed ?
Devel::Coverhas gcov support. ``` cd project_root perl Makefile.PL cover -test -gcov $BROWSER cover_db/coverage.html cover -delete ```
I have a 2d matrix created with the code: ``` for(i=0; i < size; i++) { for(j=0; j <size; j++) { a1[i][j] = i+1 + j+2; } } ``` I am trying to replicate that pattern in a matrix created by: ``` double* a = malloc(sizeof(double)*randk*randk); ``` I can't seem to figure out how to define that same pattern.
From the comp.lang.c FAQ: How can I dynamically allocate a multidimensional array?
This question already has answers here:Closed11 years ago. Possible Duplicate:How do I write a short literal in C++? I can usellto represent a long long number, I can useuto represent a unsigned number, etc. Is there a number suffix forshorttype?
The C++ standard only gives these integer suffixes (2.13.1) ``` unsigned-suffix: one of u U long-suffix: one of l L long-long-suffix: one of ll LL ``` so no, there is no suffix for shorts.
I'm currently programming in C with win32 API.I would like to know how can I permanently delete or cancel a mutex and semaphore.How can I do that, I haven't found anything about it in MSDN till now.Thanks!
You have tocloseall handles that are opened to that mutex / semaphore. If you don't own some of them, you can not.
I'm currently programming in C with win32 API.I would like to know how can I permanently delete or cancel a mutex and semaphore.How can I do that, I haven't found anything about it in MSDN till now.Thanks!
You have tocloseall handles that are opened to that mutex / semaphore. If you don't own some of them, you can not.
I'm taking a look at an application that defines a large set of constant arrays. What really confuses me is the use of two pound signs next to each other in a macro. For example: ``` #define r0(p,q,r,s) 0x##p##q##r##s ``` What do those two pound signs mean?
##provides a way toconcatenate actual argumentsduring macro expansion.
Can I set a small program that I wrote as my login shell? Instead of a regular login shell like bash? I tried googling but could not find any useful information. Any pointer is appreciated.
``` chsh -s /usr/bin/foo someuser ``` Or usevipwto edit/etc/passwd(just don't edit it directly).
GCC gives a warningimplicit declaration of function foowhen you usefoo()before its declaration. Is there any GCC flag that would make treat this warning aserrorand stop compilation? Sometime it would save you some debugging work...
-Werrorwill treatallwarnings as errors. You can be more specific with-Werror-implicit-function-declaration
Is there any flow chart generator plugin for eclipse indigo v3.7, that automatically generates the flow chart for the C/C++ code? Please help.
Doxygenhttp://www.doxygen.orgis very good :)
Currently I am debugging an embedded application in Eclipse IDE. I've got some registers to inspect, mosly ony one bit from it. Is there any way to tell Eclipse to watch only one bit in chosen register?
Easiest solutions are usually the best. You can always create another variable just for debugging purposes ``` myDebugVar = (mainVar & MASK_THAT_EXTRACTS_YOUR_BIT) >> SOME_SHIFT; ``` Now watch your new 'myDebugVar' and you are done.
Is there any specific way to convert jpeg images to black and white using C? I converted a .bmp image to black and white using C by simply extracting the headers (which in .bmp file is 54 bytes in length) and converting the RGB to the respective gray level using the formula. But how to do that in jpeg file?
If you can afford to link a library, I highly recommend OpenCV for this task:http://opencv.willowgarage.com/
GCC gives a warningimplicit declaration of function foowhen you usefoo()before its declaration. Is there any GCC flag that would make treat this warning aserrorand stop compilation? Sometime it would save you some debugging work...
-Werrorwill treatallwarnings as errors. You can be more specific with-Werror-implicit-function-declaration
Is there any flow chart generator plugin for eclipse indigo v3.7, that automatically generates the flow chart for the C/C++ code? Please help.
Doxygenhttp://www.doxygen.orgis very good :)
Currently I am debugging an embedded application in Eclipse IDE. I've got some registers to inspect, mosly ony one bit from it. Is there any way to tell Eclipse to watch only one bit in chosen register?
Easiest solutions are usually the best. You can always create another variable just for debugging purposes ``` myDebugVar = (mainVar & MASK_THAT_EXTRACTS_YOUR_BIT) >> SOME_SHIFT; ``` Now watch your new 'myDebugVar' and you are done.
Is there any specific way to convert jpeg images to black and white using C? I converted a .bmp image to black and white using C by simply extracting the headers (which in .bmp file is 54 bytes in length) and converting the RGB to the respective gray level using the formula. But how to do that in jpeg file?
If you can afford to link a library, I highly recommend OpenCV for this task:http://opencv.willowgarage.com/
What is the equivalent of cin.peek() for C programming? I need to scan files for '/r' and '/r/n' (these are the end of line markers for DOS files) so I need to "peek" ahead to the next character if the current character is a '/r' Thanks!
There isungetc(), which allows you to push characters back (as if they were not already read), when you've peeked at them. http://www.zyba.com/reference/computing/c/stdio.h/ungetc.php
I am receiving this error while compiling a C program in MinGW. As far as I know, I thought 'intptr_t' was a type in the C99 standard. Am I not including a file?
You need to includestdint.h. Note thatintptr_tanduintptr_tare indeed C99 types but they are optional.
I am trying to do ``` memset(&idt_entries, 0, sizeof(idt_entry_t)*256); ``` which produces error: cannot convert 'idt_entry_t (*)[256] {aka idt_entry_struct ()[256]}' to 'u8int{aka unsigned char*}' for argument '1' to 'void memset(u8int*, u8int, u32int)' If it helps, it is C code wraped inextern "C" {...}. Thanks!
Are you compiling this as C++? Add a cast. memset ((u8int*)idt_entries, 0, sizeof(idt_entry_t)*256);
Well, i have thislinkand i want to parse through it and get only the joke. Its in json format. I would like to use c or c++, not python because i already did it with python.
Hereis a pretty impressive list of JSON parsers. Take your pick, C and C++ are certainly both supported.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened,visit the help center.Closed11 years ago. Kindly give an detailed explanation too. How does it work ?
``` return a<b ? a : b ``` is equivalent to ``` if (a<b) return a; else return b; ```
I am implementing a user-space network device that makes use of the LinuxTUN/TAP driver. Is it possible to install a custom ioctl handler? I would like to be able to send custom status queries and control commands to the program. Or perhaps there is a slicker way of doing this?
Have the program listen on another normal socket (AF_LOCAL, AF_INET6, ... non-tun in any case) of your choice.
I am implementing a user-space network device that makes use of the LinuxTUN/TAP driver. Is it possible to install a custom ioctl handler? I would like to be able to send custom status queries and control commands to the program. Or perhaps there is a slicker way of doing this?
Have the program listen on another normal socket (AF_LOCAL, AF_INET6, ... non-tun in any case) of your choice.
I preload some lua file withluaL_loadfileand then I execute it multiple timest (it's a server). I have somedofile()calls in the lua file. WillluaL_loadfilealso preload alldofile()within the lua file?
No,luaL_loadfiledoes not executeanycode in the file, In particular, it does not call any embeddeddofile()orrequireor any other function call.
I'm familiar with only one compile time operator in C -sizeof. Are there any others that I as a programmer should be aware of?
Onlysizeofthat I'm aware, although in C99 sizeof cannot be done at compile time for variable length arrays (VLAs).
There doesn't seem to be a question for this, and it seems strange that I don't know this. When I program in c/objective-c, must I escape single quotes nested within double quotes. example "'"or"''" is this needed "\'"or"\'\'" thanks
No, escaping is unnecessary for single-quotes.
I am Just a begineer in C Programming. While solving a programming assignement I came across the need to convert an array ofunsigned chartointeger. For Example: ``` unsigned char x[]="567"; unsigned char y[]="94"; ``` Now I have to add the integer values in bothxandy. That is: ``` int sum=661; ``` What is the simplest way to do this?
You're looking foratoi().
How can I get the actual "username" without using the environment (getenv, ...) in a program? Environment is C/C++ with Linux.
The functiongetlogin_r()defined inunistd.hreturns the username. Seeman getlogin_rfor more information. Its signature is: ``` int getlogin_r(char *buf, size_t bufsize); ``` Needless to say, this function can just as easily be called in C or C++.
We have some old C code with pre-ANSI (K&R-style) function declarations. For example: ``` int foo(x, y) double x, y; { /* do some stuff */ } ``` Is there a compiler switch to enable support for this in Visual C++ 2008?
In order to get this to compile put the code in a .c file vs. a .cpp. This instructs Visual Studio to compile the code as C instead of C++
I'm familiar with only one compile time operator in C -sizeof. Are there any others that I as a programmer should be aware of?
Onlysizeofthat I'm aware, although in C99 sizeof cannot be done at compile time for variable length arrays (VLAs).
There doesn't seem to be a question for this, and it seems strange that I don't know this. When I program in c/objective-c, must I escape single quotes nested within double quotes. example "'"or"''" is this needed "\'"or"\'\'" thanks
No, escaping is unnecessary for single-quotes.
I am Just a begineer in C Programming. While solving a programming assignement I came across the need to convert an array ofunsigned chartointeger. For Example: ``` unsigned char x[]="567"; unsigned char y[]="94"; ``` Now I have to add the integer values in bothxandy. That is: ``` int sum=661; ``` What is the simplest way to do this?
You're looking foratoi().
How can I get the actual "username" without using the environment (getenv, ...) in a program? Environment is C/C++ with Linux.
The functiongetlogin_r()defined inunistd.hreturns the username. Seeman getlogin_rfor more information. Its signature is: ``` int getlogin_r(char *buf, size_t bufsize); ``` Needless to say, this function can just as easily be called in C or C++.
When creating a pointer array in c what does the effect of adding parentheses do? For example int (*poi)[2]; vs int *poi[2];
Pointer to an array of 2ints: ``` int (*poi)[2]; ``` An array of twointpointers: ``` int *poi[2]; ``` Normally Array has higher precedence than the pointer, but if you add the parentheses then the pointer comes "first".
Does the two code snipets below do exactly the same thing? ``` do { Delay_us(1); status = fetchStatus(); }while(!status); ``` Second snipet -> ``` do { Delay_us(1); }while(status = fetchStatus(), !status); ``` which is preferable?
You can do: ``` do { Delay_us(1); } while( !fetchStatus() ); ``` That way you do not need to create a local variable if youdo notuse it.
Does C have scope hiding? For example, if I have a global variable: ``` int x = 3; ``` can I 'declare' inside a function or main 'another' int x?
Yes, that's how C works. For example: ``` int x; void my_function(int x){ // this is another x, not the same one } void my_function2(){ int x; //this is also another x { int x; // this is yet another x } } int main(){ char x[5]; // another x, with a different type } ```
I need to convert a formated data to struct like this: ``` struct header { int a; int b; char c; } ``` I have to do it manually like this: ``` [data getBytes:&h.a range:(NSRange){0,4}]; [data getBytes:&h.b range:(NSRange){4,4}]; [data getBytes:&h.c range:(NSRange){8,2}]; ``` Is there a better way to convert the data to struct?
``` [data getBytes:&h range:(NSRange){0, sizeof(struct header)}]; ```
Is there any way to convert ".so" file into source code or some in readable format.
Source code is probably hard, since the .so doesn't "know" which language it was written in. But you can browse around in the assembly code by doing something like this: ``` $ objdump --disassemble my_secret.so | less ```
I am working under Linux, with two physical ethernet interfaces. I have grouped the two interfaces to a bonding interface for backup... and it works. I would like to know if there is any way to know, from my C user program, what is the active interface. Thanks
Look at/sys/class/net/bond0/bonding/active_slaveand read it using a program or code of your choice. (Replace path accordingly if using an interface name different frombond0.)
I was reading android source code in that I am not getting what doesOPEN GL ESlibrary do and what doesEGL librarydo.? Is there any relationship between this two libraries? I have looked athttp://www.khronos.org/opengles/documentation/opengles1_0/html/but still not getting.
EGL is the interface between OpenGL ES and the underlying native display platform. It is used to create & manage rendering surfaces & graphics contexts.
Does the two code snipets below do exactly the same thing? ``` do { Delay_us(1); status = fetchStatus(); }while(!status); ``` Second snipet -> ``` do { Delay_us(1); }while(status = fetchStatus(), !status); ``` which is preferable?
You can do: ``` do { Delay_us(1); } while( !fetchStatus() ); ``` That way you do not need to create a local variable if youdo notuse it.
Does C have scope hiding? For example, if I have a global variable: ``` int x = 3; ``` can I 'declare' inside a function or main 'another' int x?
Yes, that's how C works. For example: ``` int x; void my_function(int x){ // this is another x, not the same one } void my_function2(){ int x; //this is also another x { int x; // this is yet another x } } int main(){ char x[5]; // another x, with a different type } ```
I need to convert a formated data to struct like this: ``` struct header { int a; int b; char c; } ``` I have to do it manually like this: ``` [data getBytes:&h.a range:(NSRange){0,4}]; [data getBytes:&h.b range:(NSRange){4,4}]; [data getBytes:&h.c range:(NSRange){8,2}]; ``` Is there a better way to convert the data to struct?
``` [data getBytes:&h range:(NSRange){0, sizeof(struct header)}]; ```
Is there any way to convert ".so" file into source code or some in readable format.
Source code is probably hard, since the .so doesn't "know" which language it was written in. But you can browse around in the assembly code by doing something like this: ``` $ objdump --disassemble my_secret.so | less ```
I am working under Linux, with two physical ethernet interfaces. I have grouped the two interfaces to a bonding interface for backup... and it works. I would like to know if there is any way to know, from my C user program, what is the active interface. Thanks
Look at/sys/class/net/bond0/bonding/active_slaveand read it using a program or code of your choice. (Replace path accordingly if using an interface name different frombond0.)
I was reading android source code in that I am not getting what doesOPEN GL ESlibrary do and what doesEGL librarydo.? Is there any relationship between this two libraries? I have looked athttp://www.khronos.org/opengles/documentation/opengles1_0/html/but still not getting.
EGL is the interface between OpenGL ES and the underlying native display platform. It is used to create & manage rendering surfaces & graphics contexts.
Does C have scope hiding? For example, if I have a global variable: ``` int x = 3; ``` can I 'declare' inside a function or main 'another' int x?
Yes, that's how C works. For example: ``` int x; void my_function(int x){ // this is another x, not the same one } void my_function2(){ int x; //this is also another x { int x; // this is yet another x } } int main(){ char x[5]; // another x, with a different type } ```
I need to convert a formated data to struct like this: ``` struct header { int a; int b; char c; } ``` I have to do it manually like this: ``` [data getBytes:&h.a range:(NSRange){0,4}]; [data getBytes:&h.b range:(NSRange){4,4}]; [data getBytes:&h.c range:(NSRange){8,2}]; ``` Is there a better way to convert the data to struct?
``` [data getBytes:&h range:(NSRange){0, sizeof(struct header)}]; ```
Is there any way to convert ".so" file into source code or some in readable format.
Source code is probably hard, since the .so doesn't "know" which language it was written in. But you can browse around in the assembly code by doing something like this: ``` $ objdump --disassemble my_secret.so | less ```
I am working under Linux, with two physical ethernet interfaces. I have grouped the two interfaces to a bonding interface for backup... and it works. I would like to know if there is any way to know, from my C user program, what is the active interface. Thanks
Look at/sys/class/net/bond0/bonding/active_slaveand read it using a program or code of your choice. (Replace path accordingly if using an interface name different frombond0.)
I was reading android source code in that I am not getting what doesOPEN GL ESlibrary do and what doesEGL librarydo.? Is there any relationship between this two libraries? I have looked athttp://www.khronos.org/opengles/documentation/opengles1_0/html/but still not getting.
EGL is the interface between OpenGL ES and the underlying native display platform. It is used to create & manage rendering surfaces & graphics contexts.
Hello everyone I want to ask a question about includingguardsin C programming. I know their purpose but in some programms I have seen a1" written after #define like this: ``` #ifndef MYFILE_H #define MYFILE_H 1 ``` What is the purpose of this1? Is it necessary?
It's not necessary,#define MYFILE_Hshould do the trick. The fact thatMYFILE_Hisdefined(the condition tested byifndef) is separated from its value. It could be 0, ' ', 42, etc.
What is the correct term/name for the following construction: ``` string myString = (boolValue==true ? "true": "false"); ```
It's a ternary conditional expression.
Is there any standard (or widely used) simple POSIX path manipulation library for C (path join, filename stripping, etc.) ? Actually, because I'm mostly working under Windows, I currently use'shlwapi'path functions. Is there any equivalent set of functions available for POSIX paths?
path join - snprintf()filename stripping - dirname()etc. - basename(), realpath(), readlink(), glob(), fnmatch()...
Currently I am doing something like ``` "+" return TADD; ``` in my .l file to return token TADD.I want to know if there is a way I can return '+' directly so that I don't have to add a token for every operator.
Is this yacc/lex? If so, then you can just ``` "+" return '+'; ```
I'm trying to connect to an USB device that's on a remote PC (because there is no 64-bit driver for it, remote PC is 32-bit). I know the commands that I need to send to make settings on the device but I don't know how I can get connected to it. Is there a C++ or C# library that makes it possible to connect to this device on a remote PC?
You might be able to build something using Microsoft'sRemoteFXtechnology, assuming Windows is your target platform.
If I don't return anything in a function which returns something, compiler will warn about the function is not returning anything. But If I callabort()in the function, compiler won't warn. How can I mark my own function like this.
__attribute__((__noreturn__))should do it for Clang or GCC. Since you've tagged your question for Objective-C, that should do it for you!
i need to get a list or any other enumerable class with info about any connected SCSI-disks, with info just like/proc/scsi/sg/devicesPlease help me and thanks in advance
You've basically named a solution in your question -- just open/proc/scsi/sg/devicesand read from it.
For a weekend project I'm looking for a micro web-framework like bottle.py (http://bottlepy.org) but for plain old C. Sadly Google was not very helpful. Any suggestions are welcome!
After some more search I foundlibSoup, which looks very nice and is really easy to use. But beware: libSoup is part of GNOME - so this might not be so micro after all when it comes to dependencies.
Is there a way to create a True Type Font file programmatically inobjective-c? I found this reference,http://developer.apple.com/fonts/TTRefMan/index.html, but it doesn't seem there are any built in methods to accomplish this. Suggestions? Guidance?
No, there isn't any procedural font creation code. Your best bet would be to start with FontForge:http://fontforge.sourceforge.net/
I want to use shared memory, but i want only my application instances to be able to access this memory, somehow want to protect it from accessing by other applications... I am coding in C on Windows. Thanks in advance.
UseCreateFileMappingwith specificLPSECURITY_ATTRIBUTES.
I want to use shared memory, but i want only my application instances to be able to access this memory, somehow want to protect it from accessing by other applications... I am coding in C on Windows. Thanks in advance.
UseCreateFileMappingwith specificLPSECURITY_ATTRIBUTES.
How do I configure eclipse with Turbo C++ compiler.
Short answer: don't! Embarcadero Technologies (which acquired all of Borland's compiler tools with the purchase of its CodeGear division in 2008) discontinued the support of Turbo C++ 2006. Why use a tool that was abandoned 6 years ago? Turbo C++ was succeeded by C++Builder, which has it's own IDE. If you want to do C++ development in Eclipse you should useEclipse IDE for C/C++ Developers (~107MB).
I know it is a Macro we are passing to a function. How do you explain what is the use of this macro, and in which scenario i have to use this ?.
_GNU_SOURCEenables GNU extensions to the C and OS standards supported by the GNU C library, such asasprintf. Define it when you're using such non-standard functions and macros.
Could anybody tell me please how can I get framerate of WM_PAINT message in frames per second? I'm trying to make a software renderer, and framerate is very important for debugging.
This question was asked previouslyhere. As an additional hint, you can use a dynamically allocated structure to store your FPS-related variables and useSetWindowLongPtrto store a pointer to this structure.
I am using cvCanny function in opencv 2.3 it compiles fine,but while executing it gives an error saying 'tbb.dll' not found. What is the use of this dll and where can I find this?? thanks,
It's part of Intel'sThreading Building Blockslibrary. You can find a copy of it in your OpenCV install in/build/common/tbband under the platform and compiler your are using. For example, inc:\OpenCV-2.3.1\build\common\tbb\intel64\vc9
Could anybody tell me please how can I get framerate of WM_PAINT message in frames per second? I'm trying to make a software renderer, and framerate is very important for debugging.
This question was asked previouslyhere. As an additional hint, you can use a dynamically allocated structure to store your FPS-related variables and useSetWindowLongPtrto store a pointer to this structure.
I am using cvCanny function in opencv 2.3 it compiles fine,but while executing it gives an error saying 'tbb.dll' not found. What is the use of this dll and where can I find this?? thanks,
It's part of Intel'sThreading Building Blockslibrary. You can find a copy of it in your OpenCV install in/build/common/tbband under the platform and compiler your are using. For example, inc:\OpenCV-2.3.1\build\common\tbb\intel64\vc9
Тhese are my calculations ``` float c = 5.0 * (12.0 - 32.0) / 9.0; printf("%f.2", c); ``` Result is -11.111111.2 but I expected to be -11.11. What is wrong ?
The format specifier should read"%.2f". In what you have right now, the.2is misplaced. This is why you get more digits than expected, and why the.2appears verbatim at the end of the output.
I want to perform a canny edge detection in opencv 2.3,coding in c language. But when I am using cvCanny for the same purpose it gives an error as unresolved external symbol _CvCanny,though I have used a proper prototype of CvCanny. Is there any library that i have forgot to include or what? Regards,
You cannot link because you didn't add the correct path/ libraries to your project
What is the preferred way to compile.c/.cppfiles similar togcc(Linux) incmd(Windows)? What are the most common compilers?
I've never used this but it looks like it might be what you're looking for.http://www.mingw.org/ I think most people use Cygwin.http://www.cygwin.com/
I know that this may be common knowledge, but is there a way to edit RGB values of pixels of Windows window fromC/C++without using libraries likeOpenGLorDirectX? If there is, what are the built-in functions to manipulate pixel buffer directly?
In yourWM_PAINThandler you can callSetPixel.
I want to know that how can we allocate a memory block atrun-timein C or C++ without usingmallocandcallocfunctions.
In C, usemalloc. Don't forget tofreeafter use. In C++, usenewand don't forget todelete. Or better, usestd::vectorif you want a dynamic array.
What is the preferred way to compile.c/.cppfiles similar togcc(Linux) incmd(Windows)? What are the most common compilers?
I've never used this but it looks like it might be what you're looking for.http://www.mingw.org/ I think most people use Cygwin.http://www.cygwin.com/
I know that this may be common knowledge, but is there a way to edit RGB values of pixels of Windows window fromC/C++without using libraries likeOpenGLorDirectX? If there is, what are the built-in functions to manipulate pixel buffer directly?
In yourWM_PAINThandler you can callSetPixel.
I want to know that how can we allocate a memory block atrun-timein C or C++ without usingmallocandcallocfunctions.
In C, usemalloc. Don't forget tofreeafter use. In C++, usenewand don't forget todelete. Or better, usestd::vectorif you want a dynamic array.
TheUbuntu equivalentwould belibc6-dev, but I can't seem to find it for Solaris? How can I get types.h and related files for building packages on Solaris or Illumos?
You need the system/header package. I found this viahttp://pkg.oracle.com/solaris/release/en/search.shtml?token=types.h&action=Search
I want to use the unixcryptfunction in an OpenCL program. Does something like that already exist or will I have to translate it on my own?
You've probably found an answer by now, but in case anyone else comes here from a search, John The Ripper is open source and has OpenCL acceleration for several hashing algorithms, including the 3DES used in BSD crypt(). https://github.com/magnumripper/JohnTheRipper/tree/bleeding-jumbo/src/opencl
Is there a C function that doesn't wait for input but if there is one, it detects it? What I'm trying to do here is continue a loop endlessly until any key is pressed. I'm a newbie, and all the input functions I've learned so far waits for the user to input something.. I hope I'm clear, although if I'm not I'm happy to post the code..
WIndows kbhit( ) does exactly thisnon-blocking keyboard char-ready check, and there's a kbhit( ) for Linuxover here
Is there a C function that doesn't wait for input but if there is one, it detects it? What I'm trying to do here is continue a loop endlessly until any key is pressed. I'm a newbie, and all the input functions I've learned so far waits for the user to input something.. I hope I'm clear, although if I'm not I'm happy to post the code..
WIndows kbhit( ) does exactly thisnon-blocking keyboard char-ready check, and there's a kbhit( ) for Linuxover here
Is there a C function that doesn't wait for input but if there is one, it detects it? What I'm trying to do here is continue a loop endlessly until any key is pressed. I'm a newbie, and all the input functions I've learned so far waits for the user to input something.. I hope I'm clear, although if I'm not I'm happy to post the code..
WIndows kbhit( ) does exactly thisnon-blocking keyboard char-ready check, and there's a kbhit( ) for Linuxover here
IN LINUX: Not sure if it is possible. I have 100 source file, and 100 respective executable files. Now, given the executable file, is it possible to determine, respective source file.
I guess you can give this a try. ``` readelf -s a.out | grep FILE ``` I think you can add somegrepandsedmagic to the above command and get the source file name.
What is the difference between these three functions ?
Those aren't standard functions, but usually it's the return type: signed int, unsigned, and 32-bit respectively.
I am having trouble on connecting my C program to mysql. I've done most of the research but seems its quite difficult. Can someone please help? the image below shows the error using the command I typed to compile the code. Your answers are highly appreciated. BTW, I am a windows user.
It looks like your LD_LIBRARY_PATH isn't set. I believe you need that to be able to find the libraries required by the linker.
Is installed CUDA capable graphics card necessary (in Linux) for compiling CUDA programs withnvcc? Or one can compile programs everywhere and run only on such systems?
No, a graphics card is not necessary for compilation. You don't even need one to run the program; you can have it emulated in software. UPDATEOk, apparently, SW emulation hasn't been supported since CUDA 3.0.
I am having trouble on connecting my C program to mysql. I've done most of the research but seems its quite difficult. Can someone please help? the image below shows the error using the command I typed to compile the code. Your answers are highly appreciated. BTW, I am a windows user.
It looks like your LD_LIBRARY_PATH isn't set. I believe you need that to be able to find the libraries required by the linker.
Is installed CUDA capable graphics card necessary (in Linux) for compiling CUDA programs withnvcc? Or one can compile programs everywhere and run only on such systems?
No, a graphics card is not necessary for compilation. You don't even need one to run the program; you can have it emulated in software. UPDATEOk, apparently, SW emulation hasn't been supported since CUDA 3.0.
Is there any library for q-encoding? I need to decode some q-encoded text, such as: ``` **Subject: =?iso-8859-1?Q?=A1Hola,_se=F1or!?=** ```
GNU Mailutils libmailutilsis one example of such library. "Q"-encoding is specified byRFC 2047so using it as a search term gives you other relevant results.
When I use C programs, many of them defines their own error mechanisms. For that cases, I can follow their definition. How about C base libraries? Is it enough with onlyerrno?
You have to look at each function you call and then handle the return value orerrnosetting as appropriate. There is no general error handling (e.g. exceptions) beyond that.
Is there a #define that indicates whether Visual Studio is compiling in 64bit mode? I'd like to be able to include some code conditionally like so ``` #ifdef _IS_64BIT ... #else //32 bit ... #endif ``` I know I can create a flag myself, but I'm wondering if the compiler provides one.
``` #ifdef _WIN64 ... #else ... #endif ``` Documented onMicrosoft docs
I was wondering if there is a way to get the installed memory type in Windows? I mean is there an API or any other way to query that on a PC there is DDR2 or DDR3 or SDRAM installed? Thanks!
CPU-IDis able to do it, so it's definitely possible. They have aSDKavailable, but it'sexpensive. QueryingWin32_PhysicalMemoryusing WMI may also help and is possible usingC/C++.
I am trying to find an integer type length in C. Does anyone have a quick algorithm to check the length of it? Thanks.
Do you mean this? ``` sizeof (int) ``` If you want it measured in bits, try ``` #include <limits.h> (CHAR_BIT * sizeof (int)) ```
I want to create a processBfrom processA. However, I don't wantBto be the child ofA, which will be the case if I simply usefork. How can I achieve that? In other words I want processBto keep on executing even if processAis killed.
You can use the setsid() function. Alternatively, as you have tagged your question "linux", maybe you want to use daemon() instead of fork() + setsid().
how do I allocate memory forstrlen(esc)in a proper way? Thetempandstrare char datatypes. ``` double esc = t1.tv_sec+(t1.tv_usec/1000000.0); strAll = malloc(strlen(temp) + strlen(str) + strlen(esc) + 1); ```
You cannot takestrlen(esc). As I am sure the compiler has already told you, the argument tostrlen()must bechar *, you are passing it adouble. Try first converting thedoubleto array ofcharwithsnprintf().
Is there a #define that indicates whether Visual Studio is compiling in 64bit mode? I'd like to be able to include some code conditionally like so ``` #ifdef _IS_64BIT ... #else //32 bit ... #endif ``` I know I can create a flag myself, but I'm wondering if the compiler provides one.
``` #ifdef _WIN64 ... #else ... #endif ``` Documented onMicrosoft docs