c

How to perform RGB->YUV conversion in C/C++?

How to perform RGB->YUV conversion in C/C++? I have some Bitmap.. RGB I need to convert it to YUV Libs? Tuts? Articles? ...

undeclared identifier error occurs when I already have declared the variable

I got an undeclared identifier error from the follow code, but i have clearly declared the variable "length" in both cases. what did I do wrong? int startWordLenRec(char s[]) { if (isLetter(s) == false){ int length = 0; } else if{ int length = 1 + startWordLenRec(s+1); } return length; } ...

How to submit a change or request clarification to ISO technical committee

I submitted a question on 'prototype scope' and wanted to know the reason for its origination. After some serious deliberations (please see the answers there) I think a clarification regarding the existence of the 'prototype scope' is needed. I am thinking of how it has to be done? What is the process for submitting a request (for cla...

Finding the length of a word at the beginning of a string with recursion

I've written the code below to calculate the length of a word at the beginning of a string with recursion. I've thought of a case in which my code would not work " #@*hello " what do I need to modify the code to resolve this problem (the correct answer is 5)? Thanks int startWordLenRec(char s[]) { int length; if (isLe...

What does 'y' in the output stand for in C?

Hi All, I have a problem, I construct a string in a loop and the output of that string to stout displays the string and a character 'y' with two dots above it as the last character. What is that? I create the string in this function: char get_string(char *buf, int ble, FILE *fp, char del) { int i = 0; int c; char result;...

Binary search in C with recursive function accepting only length

I am solving "Programming Pearls" exercises. 4.11 say: Write and prove the correctness of a recursive binary search function in C or C++ with this declaration: int binarysearch(DataType x[], int n); Use this function alone; do not call any other recursive function. I came up with: int bsearch_rec_array_only(int key...

Copying from double pointer to int array. Is this correct?

I have a double pointer data->mono_channel, where I would like to cast all the doubles to integers and put them in an array. int frames = data->audio_info_save->frames; short buffer[frames]; double* p; int i = 0; for (p = &(data->mono_channel)[0]; p < &(data->mono_channel)[frames]; p++) { buffer[i] = (int) *p; i++; } The purpose i...

Any guaranteed minimum sizes for types in C?

I asked a similar question before but I'm still confused... can you generally make any assumptions about the minimum size of a data type? What I have read so far char 1 Byte short 2 Byte int 2 Byte, typically 4 Byte long 4 Byte float??? double??? Are the values in float.h and limits.h system dependent? Thx again, Oliver ...

find squareroot with a loop

double sqrtIt(double x, double low_guess, double high_guess) { int n = 10; int num = 0; while ( n > 0.000000000000001){ n = n / 10; while (num < x && low_guess <= (low_guess * 10)){ low_guess = low_guess + n; num = low_guess * low_guess; } } return low_guess; } I've tried to use the code...

Is it safe to use a temporary sockaddr_in when using connect() in C?

Using sockets in C, is it safe to do this in a function? int ConnectTo(char *ip, int port){ struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); inet_pton(AF_INET, ip, &addr.sin_addr.s_addr); addr.sin_port = htons(port); int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if(connect(sock, (struct sockaddr ...

How do I use merge sort to delete duplicates?

I use recursive merge sort for sorting a link list, but during the merge sort I would like to delete duplicates. Anyone has insight in how to accomplish this? I am using C code. ...

OpenSSL "Seal" in C (or via shell)

I'm working on porting some PHP code to C, that contacts a web API. The issue I've come across is that the PHP code uses the function openssl_seal(), but I can't seem to find any way to do the same thing in C or even via openssl in a call to system(). From the PHP manual on openssl_seal(): int openssl_seal ( string $data , str...

How to get internal IP, external IP and default gateway for UPnP

I'm wondering how I'd go about getting the: Internal IP address; External IP address; and Default gateway in Windows (WinSock) and Unix systems. Thanks in advance, ...

Non-blocking socket on Windows doesn't return after send() call

I'm hoping someone can explain a situation -- any situation -- in which a non-blocking Windows socket would not immediately return after using send() on it. On other platforms, my code works as intended, so it appears to be a Windows-specific issue. The way I can tell it isn't returning is quite simple: I cout a message immediately befo...

Number of calls for nth Fibonacci number.

Consider the following code snippet: int fib(int N) { if(N<2) return 1; return (fib(N-1) + fib(N-2)); } Given that fib is called from main with N as 10,35,67,... (say), how many total calls are made to fib? Is there any relation for this problem? PS: This is a theoretical question and not supposed to be executed. EDIT: I am...

Why I can't pass two chars as function arguments in C?

I have a function: int get_symbol(tab *tp, FILE *fp, char delim) and I call it like this: get_symbol(tp, fp, ';') I always have it declared in the header as: int get_symbol(tab *, FILE *, char); No this all works fine, I can execute the code in the function and the delim is set. But if I try to add one more char to the function'...

Generate assembler code from C file in linux

Hi I would like to know how to generate assembler code from a C program using Unix. I tried the gcc: gcc -c file.c I also used firstly cpp and then try as but I'm getting errors. I'm trying to build an assembler program from 3 different programs prog1.c prog2.c prog.h Is it correct to do gcc -S prog1.c prog2.c prog.h? Seems that i...

HOW to use OpenSSL in C to send email (via gmail) using SMPTS (TLS)

Writing in C/C++ (not COM C#) As a follow on from these questions: http://www.developerweb.net/forum/showthread.php?t=3477 http://stackoverflow.com/questions/440762/openssl-command-line-troubles http://stackoverflow.com/questions/1246742/how-to-translate-openssl-sclient-starttls-smtp-command-to-c-code http://stackoverflow.com/questio...

Concatenating strings in macros - C++

What's the easiest way to concatenate strings defined in macros. i.e. The pseudo code I'm looking for would be like: #define ROOT_PATH "/home/david/" #define INPUT_FILE_A ROOT_PATH+"data/inputA.bin" #define INPUT_FILE_B ROOT_PATH+"data/inputB.bin" ... #define INPUT_FILE_Z ROOT_PATH+"data/inputZ.bin" The only way I know of is to use st...

Any likely causes of a double-free in ncurses?

I have an ncurses app that does the following, sometimes instantly after launch, sometimes after some fiddling. malloc: *** error for object 0x100300400: double free Program received signal SIGABRT, Aborted (gdb) where #0 0x00007fff846a7426 in read () #1 0x00007fff83f3d775 in _nc_wgetch () #2 0x00007fff83f3de3f in wgetch () (and so on i...