c

Concatenating file with path to get full path in C

Using C, I'm trying to concatenate the filenames in a directory with their paths so that I can call stat() for each, but when I try to do using strcat inside the loop it concatenates the previous filename with the next. It's modifying argv[1] during the loop, but I haven't worked with C in a long time, so I'm very confused... #include <...

How do I detect an operator vs. int in C using scanf?

How do I read in the following input in my RPN calculator so that it will find the operator no matter what order? 2 2+ 4 As of now my scanf only sees the first char in the string and I can only do this: 2 2 + 4 I'm also trying to add an option for integer vs floating point mode. (ex. when 'i' is entered, operate in floating point a...

HEX assignement in C

Hi, I have generated a long sequence of bytes which looks as follows: 0x401DA1815EB560399FE365DA23AAC0757F1D61EC10839D9B5521F..... Now, I would like to assign it to a static unsigned char x[]. Obviously, I get the warning that hex escape sequence out of range when I do this here static unsigned char x[] = "\x401DA1815EB56039.....";...

iphone/objective c (simple) question

hi guys I'm trying to avoid the redeclaration of self, in the following picker2.peoplePickerDelegate = self; // showing the picker [self presentModalViewController:picker2 animated:YES]; Why am i not able to just go like: [picker2.peoplePickerDelegate presentModalViewController:picker2 animated:YES]; Regards ...

Long Integer and Float

If a Long Integer and a float both take 4 bytes to store in memory then why are their ranges different? ...

How to implement you own custom DirectShow renderer?

How to implement you own custom DirectShow renderer that could work a-la or instead of SampleGrabber? ...

How to receive and play back a SHOUTcast audio stream on the mac or iphone?

Are there solutions in C or Objective-C to receive and play back SHOUTcast audio streams on the mac or iphone? ...

what is the meaning of '=='..in C?

What is the meaning of == and how does it differ from =? How do I know which one to use? And how can I type the two vertical lines for the OR logical operator? ...

Are there open source audio stream clients or frameworks?

I'm looking for how to play back audio streams in these formats: MP3 Ogg / Vorbis WMA over MMS/ASF AAC / AAC+ target is the mac and iPhone. Maybe there is an open source library that I could look at, to understand how it works, and then port it to the cocoa frameworks somehow. ...

Get a pointer to the current function in C (gcc) ?

Hi, is there a magic variable in gcc holding a pointer to the current function ? I would like to have a kind of table containing for each function pointer a set of information. I know there's a _func_ variable containing the name of the current function as a string but not as a function pointer. This is not to call the function th...

Is it safe to allocate memory for buffers on external dll and use it on main application?

As in topic.. I've found something like this in one application. In main C application we have declaration: void* buff = NULL; and later there is a call: ReadData(&buff); SaveToFile(buff); SaveToFile() is a C function from main function. ReadData(void* * ) is a C++ function from external dll. In this function memory for buffer is...

MD5 implementation in C for a XML file

Hi, I need to implement the MD5 checksum to verify a MD5 checksum in a XML file including all XML tags and which has received from our client. The length of the received MD5 checksum is 32 byte hexadecimal digits. We need set MD5 Checksum field should be 0 in received XML file prior to checksum calculation and we have to indepandantly...

Why is atoi returning random numbers?

I am trying to read in data from a text file (the time). and convert that into something that can be DiffTime'ed to the current system time. I am now so close to getting this working correctly, I can taste it but I am stuck with an issue I cannot work out. (I have a very basic grasp of the C language). this program reads in the data fr...

Two '==' equality operators in same 'if' condition are not working as intended.

I am trying to establish equality of three equal variables, but the following code is not printing the obvious true answer which it should print. Can someone explain, how the compiler is parsing the given if condition internally? #include<stdio.h> int main() { int i = 123, j = 123, k = 123; if ( i == j == k) ...

How to handle all errors, including internal C library errors, uniformly

I wanted to handle all internal errors gracefully, without program termination. As discussed here, using _set_se_translator catches divide-by-zero errors. But it does not catch, for example, C runtime library error -1073740777 (0xc0000417), which can be caused by format strings for printf which have the percent sign where they shoul...

what is scanf("%*s") and scanf("%*d") format identifiers ?

What is the practical use of the formats "%*" in scanf(). If this format exists, there has to be some purpose behind it. The following program gives weird output. #include<stdio.h> int main() { int i; char str[1024]; printf("Enter text: "); scanf("%*s", &str); printf("%s\n", str); printf...

How do C compilers implement functions that return large structures?

The return value of a function is usually stored on the stack or in a register. But for a large structure, it has to be on the stack. How much copying has to happen in a real compiler for this code? Or is it optimized away? For example: struct Data { unsigned values[256]; }; Data createData() { Data data; // initialize d...

Convert a string into an integer - each representation

Is there a function or library that can convert any (default, octal, hex, ...) integer in C given as a char[] into an unsigned long long int ? Examples: 1 1l 1ul 42e+10 0x2aLL 01234u ... atoi has some problems with 0x... and the suffixes u/l. ...

How do you remove multiple files in C using wildcards

Is there any way in C to remove (using remove()) multiple files using a * (wildcards)? I have a set of files that all start with Index. For example: Index1.txt Index-39.txt etc. They all start with Index but I don't know what text follows. There are also other files in the same directory so deleting all files won't work. I know you can...

How do you query a pthread to see if it is still running?

In my destructor I want to destroy a thread cleanly. My goal is to wait for a thread to finish executing and THEN destroy the thread. The only thing I found about querying the state of a pthread is pthread_attr_setdetachstate but this only tells you if your thread is: PTHREAD_CREATE_DETACHED PTHREAD_CREATE_JOINABLE Both of those h...