c

Substring Extraction problem

Given 2 strings, write a function that returns the position of String B that matches String A if String A is a substring of String B. Otherwise return -1. Example: strA = "ello" strB = "Hello_World" Your function should return 1. strA = "blah" strB = "blha" Your function should return -1. ...

Free C Language IDEs?

Googling for "c ide -C++" produces too many results for C++, as well as unrelated results. These search terms seem too short to produce relevant results. Does anyone have a link to a free, Win32 C IDE that does step-through debugging like Visual Studio? ...

edit a body of text from the command line in C

I am writing some small program in C--some log in, log out, create account, send message to another account deal--that I can build on and change and innovate and polish up to refine my skills in C. What I am trying to figure out how to implement is part of the "compose message" option. After you are prompted for the recipient, subject, ...

memcpy not doing as it is supposed to

I have this bit of code that is outputting the wrong results. #include <stdio.h> #include <string.h> int main() { unsigned char bytes[4]; float flt=0; bytes[0]=0xde; bytes[1]=0xad; bytes[2]=0xbe; bytes[3]=0xef; memcpy( &flt, bytes, 4); printf("bytes 0x%x float %e\n", flt, flt); return 0; } the output that I get ...

Programmatically generate a C Win32 DLL.

I need to repeatedly generate a Win32 DLL with a registration information function. This function uses literals to return customer specific registration information, with a separate DLL being built per customer. I have a test version working correctly, with hard-coded information for one customer. The urgency for some sites dictates I...

What does .h and .m stand for?

Exact duplicate: Why do Objective C files use the .m extension? I'm thinking .h stands for header. I suppose .m could stand for main, but I don't know. Do any of you actually know this? Just to clarify, I know what goes in which file, i.e. I know the purpose of each filetype, I'm just curious if the filetype symbol has a meaning. ...

Unable to get a factorial function to work in C

I cannot get the following code to work. #include <stdio.h> // I am not sure whethere I should void here or not. int main() { // when the first bug is solved, I put here arg[0]. It should be // similar command line parameter as args[0] in Java. int a=3; int b; b = factorial(a); // bug seems t...

Under a debugger

How do I detect in my program that it's being run under a debugger? I am aware that this seems to indicate that I try to do something I shouldn't, and that is too messy. I think it is an interesting question tho. Specifically, is there a way to do it in a POSIX environment? For example using sigaction (2) to detect that some handler ...

Reading floats

How could i read..let's say 10 floats and add them in an array without wasting any memory? ...

Count bits in the number.

Duplicate: Best algorithm to count the number of set bits in a 32-bit integer? Suppose you have a number. Is there any way to count the bits which equals to 1 in binary representation of that number, not using iteration? I mean, is there any way to do it in constant time using some bitwise operators and masks. I need solution whi...

C Program argv does not contain double quotes

I want to write c program which calls another exe. This wrapper c program does nothing but sets some environment variable before I call my original exec. For example My original exec name is test.exe and I wrote testwrapper.exe I want to call it as testrapper.exe < parameter >, internally it will should call test.exe < parameter > My pr...

Displaying a bitmap on a "BUTTON" class window in WIN32

Edit: I think the WM_CREATE message isn't sent during the creation of child windows (namely my button). So by calling SendMessage during WM_CREATE, I'm sending a message to a window that hasn't been created yet. The solution for now is to call SendMessage() during the WM_SHOWWINDOW message. Do child windows send WM_CREATE messages at c...

Programming against a database in C

Hello, I want to program against various databases in C. I want to know if all of the major database providers, Oracle, DB2, Sql Server, MySql have an api to use for C. If they all do can you give me some links to what the are but more specifically, how to work with the api? thanks ...

Is there a truly safe formatting library for C?

Bearing in mind the answers given to a question about a safer formatting library for C, I'm wondering whether there is a safe C formatting library? What I mean is: there's no possibility to mismatch the format string from the arguments there's no possibility to crash by passing the wrong type there're no platform-dependent aspects P...

C GUI, with a C++ backbone?

I have a simple (and also trivial) banking application that I wrote in C++. I'm on ubuntu so I'm using GNOME (GTK+). I was wondering if I could write all my GUI in C/GTK+ and then somehow link it to my C++ code. Is this even possible? Note: I don't want to use Qt or GTKmm, so please don't offer those as answers. ...

peek at input buffer, and flush extra characters in C

If I want to receive a one character input in C, how would I check to see if extra characters were sent, and if so, how would I clear that? Is there a function which acts like getc(stdin), but which doesn't prompt the user to enter a character, so I can just put while(getc(stdin)!=EOF);? Or a function to peek at the next character in th...

initializng a C array with repetitive data

I would like to initialize an array of structs, with the same element repetitively, ie struct st ar[] = { {1,2}, {1,2}, {1,2} }; However I do NOT want to run any code for that, I wish that the layout of the memory upon program's execution would be like so, without any CPU instructions involved (it would increase boot time on very slow...

Is there a convenient function in objective-c / coca-touch to find a lowest number?

I have two numbers, and need to get returned the lower one. Is there any function I could use? Sure it's a easy task, I could do an if-statement. I just want to know. ...

How to Initialize a Multidimensional Char Array in C?

I'm trying to convert some code from C# to C so that it can be burnt onto a microcontroller. Could someone please tell me how I would convert a two dimensional string array in C# into something in C? My C# code looks like this: string[,] DirectionPosition = {{"00", "10", "", "01", ""}, {"01", "...

Changing one byte in a file in C

Let's say I have a file stream open and ready. How do I seek a single byte in the stream and change it so that change is reflected on the file? ...