I was curious about the performance of insert-sort using C and python but the results I've got just make me think if I've done something wrong. I suspected that C would be faster, but not that much.
I've profiled both codes and the insert-sort function is the place where the time is most spent.
Here is the C function:
void
insert_sort...
When programming C for the command console, what happens when you have a function that tries to use SCANF to ask user input for a CHAR variable, and the user types CTRL+Z (EOF) and hits enter?
For example:
char promptChar()
{
char c;
printf("Enter a character: ");
scanf("%c", &c);
return c;
}
If the user types CTRL+Z ...
I am trying to figure out what version of Boost my code thinks it's using. I want to do something like this:
#error BOOST_VERSION
but the preprocessor does not expand BOOST_VERSION.
I know I could print it out at run-time from the program, and I know I could look at the output of the preprocessor to find the answer. I feel like having...
I have very limited knowledge of using C Builder, could you give me an example or point me to tutorial showing how to use FindNextChangeNotification in Delphi or ,if it is possible, how to use the C component in delphi?
...
Hi,
We can do left shift operators in C/C++ for faster way to multiply integers with powers of 2.
But we cannot use left shift operators for floats or doubles because they are represented in different way, having an exponent component and a mantissa component.
My questions is that,
Is there any way? Like left shift operators for int...
void reverse(char *str){
int i,j;
char temp;
for(i=0,j=strlen(str)-1; i<j; i++, j--){
temp = *(str + i);
*(str + i) = *(str + j);
*(str + j) = temp;
printf("%c",*(str + j));
}
}
int main (int argc, char const *argv[])
{
char *str = "Shiv";
reverse(str);
printf("%s",str);
return 0;
...
How should I approach implementing a USB device driver for Windows? How should I take into account different versions of windows e.g:
- Windows XP
- Windows Vista
- Windows 7
Is there open source solutions which could be used as a starting point? I'm a total newbie to windows driver development.
We have an embedded device with USB d...
I am using a va_list to construct a string that is rendered.
void Text2D::SetText(const char *szText, ...)
This is all fine and good, but now the user has the ability to change the language while the application is running. I need to regenerate all the text strings and re-cache the text bitmaps after initialization. I would like to ...
I am having trouble getting this to work.
I have variables initiated in main which I want to pass onto other functions and have changed. I know the only way this can be done is with pointers or to declare the variables outside the main function.
I would prefer to use pointers
How is it done?
eg
int main(){
int variable1 = 5;
...
I'm looking for an example of how to use the realpath function in a C program. I can't seem to find one on the web or in any of my C programming books.
...
Are there any IDE's or plugins to one that will expand/preprocess a macro and show their results inline without compiling?
I've found a couple of other questions that are related, but they require compiling.
...
I'm having trouble understanding what an "index of rows of a" in the problem is referring to... can you give me an example of that? Why does
sum = sum + a[(row * a_cols) + k] * b[k * b_cols + col]?
Thank you!
double dotProduct(double a[], const unsigned a_rows, const unsigned a_cols,
/* a is a matrix with a_rows ro...
So I'm trying to get the C program to read a filename from the command line in the following format:
cat (filename path) | (program name)
i can get it to read the name of the input file when its entered as a command line argument, but it won't read from the concatenated argument
here's the code, right now its reading the name of the fi...
The following block is nested by Huffman block markers
-HUFF---------------------------------------------------------------------0084-
10 0 1 2 4 3 4 6 5 6 8 a 9 4 2 3
0 1 2 11 0 3 4 21 5 12 31 6 41 51 61 13
22 71 81 91 a1 14 32 b1 d...
Hi,
This is my first ever attempt at writing a recursive function in c. The following-code works. I apologize for the long posting, but I am trying to be as clear as possible.
I am trying to generate a tree where each node (inode) has an integer field "n". Correspondingly, each inode has an array of pointers to "n" other inodes. Func...
How can get exact total space of a drive via c in linux?
not use shell script.just c,
thanx
...
When compiling, C produces object code before linking time.
I wonder if object code is in the form of binary yet?
If so, what happened next in the linking time?
...
I was reading through this Advanced Linux Programming tutorial when I encountered a problem. I was trying to eject the CD-ROM drive using this code:
int fd = open(path_to_cdrom, O_RDONLY);
// Eject the CD-ROM drive
ioctl(fd, CDROMEJECT);
close(fd);
Then I try to compile this code and get the following output:
In file included from ...
Is there a science/math related C/C++ programming library that includes functions for mathematical integration? This might be useful for finding values for a cumulative distribution function, etc. Symbolic manipulation ideal but not required.
Thanks!
P.S. I've looked at GSL but it does not contain functions specific for integration.
...
I would like to read a EAN-13 bar-code from an image in C.
I found the OpenCV library that should help me to compute the image as well as an article about an iPhone App that can read Sudoku.
But in an other hand, I found an opensource library to read DataMatrix bar-code.
I would like to join an existing OpenSource project about reading...