c

Finding a median using SSE2 instruction set

Hello, My input data is 16-bit data, and I need to find a median of 3 values using SSE2 instruction set. If I have 3 16-bits input values A, B and C, I thought to do it like this: D = max( max( A, B ), C ) E = min( min( A, B ), C ) median = A + B + C - D - E C functions I am planing to use are : max - _mm_max_epi16 min - _mm_min_e...

Compiling with header files

Compiling the file main.c with: gcc main1.c -o final gives me: /tmp/cc1cwhAP.o: In function `main': main1.c:(.text+0xb): undefined reference to `hi' main1.c:(.text+0x15): undefined reference to `hi' collect2: ld returned 1 exit status main1.c: #include <stdio.h> #include "incl.h" int main(void) { hi = 1; printf("hi = %d",hi); ...

how do i print output as 5 of the following program?

# include <stdio.h> int x = 5; int main(void) { int x = 7; printf("output = %d\n", x); } The above program shows output as 7. How to print 5 in c? thanx... ...

fgetc does not identify EOF

Below program runs fine on solaris/linux various flavor, but not on AIX. on AIX while(c!=EOF) if i replace by while(c!=0xff) it just run fine completely Any thought ? i checked the man page of fgetc on aix, and it should return EOF constant ! #include <stdio.h> #include<unistd.h> #include <string.h> int main() { char c; FI...

How to get Current System IP in C under Windows XP

How can I get current system IP using c under window XP. ...

CUDA kernels throw different results on 2 different GPUs(GeForce 8600M GT vs Quadro FX 770M)

Hi everybody, I've been working on an AES CUDA application and I have a kernel which performs ECB encryption on the GPU. In order to assure the logic of the algorithm is not modified when running in parallel I send a known input test vector provided by NIST and then from host code compare the output with the know test vector output prov...

size limit of printf conversion specification

printf conversion specifications are % followed by flags, width, precision, length modifier and conversion specifier. Is there practical limit to size of a conversion specification? I.e. %s is 2 chars long, while %08.2f is 6 chars long. My question is, what is the length of the maximal single specification in a format string that can be...

How to avoid backslash escape when writing regular expression in C/C++

For regular expression \w+\d, in many script language such as perl/python it can be written literally. But in C/C++, I must write it as: const char *re_str = "\\w+\\d"; which is ugly to eye. Is there any method to avoid it? MACRO are also acceptable. ...

Using postfix increment in an L-value

Possible Duplicate: In what order does evaluation of post-increment operator happen? Consider the following snippet(in C): uint8_t index = 10; uint8_t arr[20]; arr[index++] = index; When I compile this with gcc, it sets arr[10] to 10, which means that the postfix increment isn't being applied until after the entire assign...

C string concatenation

I am trying to input 2 strings in C, and output a 3rd string which the concatenation of string 1 and 2. #include <stdio.h> #include <stdlib.h> #include <string.h> /* * */ int main(int argc, char** argv) { char stringarray1 [30]; char stringarray2 [30]; char stringarray3 [30]; int length; printf("Please enter s...

how to create a program

i want to create a C program ...

Why does appending a common suffix reverse the collation order in the en_US locale?

The following code #!/usr/bin/perl use strict; use warnings; my $s1 = '[email protected]'; my $s2 = '[email protected]'; my $s3 = 'aaa2000'; my $s4 = 'aaa_2000'; no locale; print "\nNO Locale:\n\n"; if ($s1 gt $s2) {print "$s1 is > $s2\n";} if ($s1 lt $s2) {print "$s1 is < $s2\n";} if ($s1 eq $s2) {print "$s1 is = $s2\n";} if ($...

Sending ctrl + z to console program

I have a simple console program written in C and want to abort a text input with CTRL + Z. How is it possible? Edit: Here is some code (untested). #include <stdio.h> int main() { float var; while(1) { scanf("%lf", &var); // enter a float or press CTRL+Z if( ??? ) // if CTRL+Z was pressed { ...

Why is my memory layout different?

The following code snippet: void (*foo)(); char X[1]; char Y[10]; could intruitively give me one possible stack layout of: | Y[10] | |---------| | X[1] | |---------| | foo | |---------| I examined this by generating the ASM file using: gcc -S -o stack stack.c Then I oberved that the order of pushing these variables is ...

Is is possible to turn off the computer fan+ the processor fan with programming?

Can we turn-off the computer fan by programming in C?If there is a way please guide me to it.Or atleast any hint would be great. ...

Problem with simple preprocessor define

Hi all, I have a simple memory mapped interface, and I would like to write through this values to two registers and then read them back. The following code example works fine: volatile int *reg1 = (int *) 0x80000000; volatile int *reg2 = (int *) 0x80000004; *reg1 = 12; *reg2 = 23; printf("reg1 = %i\n", *reg1); printf("reg...

Strange SEGFAULTS using fprintf

I'm having a very tough time debugging a multi-threaded C application that I've made a few changes to. I've been unable to use GDB to help identify the issue(see below code for more info). The following code is from one of the tasks that is opened in its own thread. I've snipped out most of the code following the problem. void tskPr...

Create a program which utilizes 2 different ISAs

Hello newcomer here (be gentle), I am attempting to write a program which has floating point code in it. However this program needs to run on 2 different processors. Which have roughly identical ISAs except for their floating point model. They use completely different instructions and registers to do floating point calculations. Wha...

How to get functions names from Linux headers located in /usr/include

We have most of Gnu C Library Headers in /usr/include I'm looking for a way to open and read an include file and parse it to print all the declared functions which are located inside it. and can any one explain or provide a link talking about this headers formatting. I doing this because I'm trying to do an C Auto completion plug-in whic...

Sign extending from a constant bit width in C#

Guys, I have a value thats 5 bits in length. 4 bits determine the number and the 5th bit determines the sign, there by holding any value between -16 and +15. How can I accomplish sign extending from a constant bit width in C#? I know in C, I can use something like the follow to accomplish this: int x; // convert this from using 5 bits ...