Ok, so I have a char stringA and char stringB, and I want to be able to insert stringB into stringA at point x.
char *stringA = "abcdef";
char *stringB = "123";
with a product of "ab123cdef"
does anyone know how to do this? Thanks in advance
...
I am preparing for a phone interview. I came upon these questions on the internet. Can anyone tell me some good answers for these?
Suppose I give you a text file and ask you a to write a program that will return a random line from the file (all lines must have equal probability to be returned)
Same as part 1, except this time the enti...
As a developer who has just finished writing thousands of lines of complex multi-threaded 'C' code in a project, and which is going to be enhanced, modified etc. by several other developers unfamiliar with this code in the future, I wanted to find out what kind of safety nets do you guys try to put in such code? As an example I could do ...
I just asked a question related to how the compiler optimizes certain C++ code, and I was looking around SO for any questions about how to verify that the compiler has performed certain optimizations. I was trying to look at the assembly listing generated with g++ (g++ -c -g -O2 -Wa,-ahl=file.s file.c) to possibly see what is going on un...
The following code crashes on the second Pop() call. I'm a novice with C and I've been staring at this code now for over an hour and i can't see the error. Any ideas to help me out on why this code is crashing?
#include <stdio.h>
#define StackDataSize 100
typedef struct Stack
{
int index;
void *data[StackDataSize];
} Stack;
v...
#define MAXBUF 1000
int buf[MAXBUF];
int buffered = 0;
int bufp = 0;
int getch()
{
if(bufp > 0) {
if(!--bufp)
buffered = 0;
return buf[bufp];
}
else {
buffered = 0;
return getchar();
}
}
void ungetch(int c)
{
buf[bufp++] = c;
buffered = 1;
}
int getfloat(float *pn)
{
...
Hello I have an extended stored procedure that sends an error message.
srv_sendmsg(pSrvProc, SRV_MSG_ERROR, errorNum, SRV_FATAL_SERVER, 1,
NULL, 0, (DBUSMALLINT) __LINE__,
buff,
SRV_NULLTERM);
I've set the severity to SVR_FATAL_SERVER just as a test to see if I can cause the message to throw an exc...
Hello all,
One line of background: I'm the developer of Redis, a NoSQL database (http://code.google.com/p/redis). One of the new features I'm implementing is Virtual Memory, because Redis takes all the data in memory. Thanks to VM Redis is able to transfer rarely used objects from memory to disk, there are a number of reasons why this w...
I am trying to build some code that is originally target at OSX/BSD/Linux for the iPhone. It uses struct rt_msghdr from route.h but as it turns out this header is not available in the iPhone SDK.
Looks like the function tries to find the available bind addresses as a list of struct addrinfo.
Does anyone have a suggestion how to proceed...
So I generally use cout and cerr to write text to the console. However sometimes I find it easier to use the good old printf statement. I use it when I need to format the output.
So one example of where I would use this is:
// Lets assume that I'm printing coordinates...
printf("(%d,%d)\n", x, y);
// To do the same thing as above us...
Hello
I wish to enumerate all desktops in a system and get the logged in user name for that desktop. So far I have the following code snippit as an example of obtaining a HDESK handle and trying to determine the user name associated with it (if any), but the call to LookupAccountSid fails with ERROR_NONE_MAPPED ("No mapping between acco...
I'm trying to modify this code in an attempt to make it work on an Arduino Mega. I'm pretty much new to C so, I may have made some major mistakes. By the way, this is for a self balancing skateboard.
This code is taken from an ATmega32 (from here and I'm trying to make it work on a Arduino Mega).
This code was writen for an ATmega32 d...
How to turn pcm audio into text using some lib written entirely in the C\C++ programming language?
So I have pcm file. I want to turn it into text. how to do it? (with speech recognizer lib of your choise (BTW i need it to work extreamly fast)
So what do I need?
Open Source Libs.
Tutorials and blog articles on How to do/use it.
...
I have an application which runs using the context menu of windows explorer. I create an ATL based DLL and register it to Windows Registry under HKCR\AllFileSystemObjects\ShellEx\ContextMenuHandlers. I am able to run my application. I want coverage for my code present in the DLL which is being registered in the registry.
I am currently ...
I am developing an application that will have to run on both Windows and Linux.
So far I have it running on Linux using GCC 4.4.1 using my Makefile.
However, I also need to compile on Windows. The source code will compile on Windows as I have #defined all the areas of the code that separate the different compilers. I.e.:
#ifdefined (L...
Dear all,
In order to creation a formatted file, I want to utilize fprintf. it must get char* but I have several string variables. Can anyone help me, please?
Thanks
...
I have an image generator which would benefit from running in threads. I am intending to use POSIX threads, and have written some mock up code based on https://computing.llnl.gov/tutorials/pthreads/#ConVarSignal to test things out.
In the intended program, when the GUI is in use, I want the generated lines to appear from the top to the ...
Hi
the below code print the biginteger to a file in decimal format ,how do i convert the code into printing binary data and hex data into the File instead ??
static void
print_pos( FILE* f, bigint bi )
{
if ( bi_compare( bi_copy( bi ), bi_10 ) >= 0 )
print_pos( f, bi_int_divide( bi_copy( bi ), 10 ) );
putc( bi_int_mo...
Free of charge, simple to learn/use, Cross Platform C library for GUI Apps? Am I looking for Qt?
Bonus question: Can I develop with the said library/toolkit on Mac then recompile on PC/Linux?
Super Bonus Question: Link to tutorial and/or download of said library.
(RE)EDIT:
The truth is that I'm in the process of catching up on the C...
I recently asked a question about importing from a list of source/header files in Eclipse
I haven't found a good solution to this, so I thought I'd check out other IDEs. I want an IDE that does not need to "own" everything from a top directory and down. When creating a new project I want to have a text file that lists source/header fil...