I have a string representing an integer with spaces -- digits are grouped by three.
I was considering using strchr and strcat, as in:
char* remove_spaces (char* s)
{
char* space;
while (space = strchr(s, ' '))
{
*space = '\0';
strcat(s, space + 1);
}
return s;
}
But, first, I'm not sure it is safe...
The Problem was to find and replace a string in a C File.
I am new to C Files. I have tried the following code but I didnt get any output:
#include<stdio.h>
#include<string.h>
int main()
{
FILE *f1,*f2;
char *src,*dest,*s1,ch,ch1,ch2,ch3;
int i;
f1=fopen("input.txt","rw");
f2=fop...
My OpenGL application which was working fine on ATI card stopped working when I put in an NVIDIA Quadro card. Texture simply don't work at all! I've reduced my program to a single display function which doesn't work:
void glutDispCallback()
{
//ALLOCATE TEXTURE
unsigned char * noise = new unsigned char [32 * 32 * 3];
memset(noise, 255...
#include <stdio.h>
#include <unistd.h>
//#include <iostream.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/types.h>
int t_array[100];
int h_array[100];
int race_length=0;
void cursor(int y)
{
int i;
printf("%c[%d;%df",0x1B,y,0);
}
void turtle_fun()
{
int Ti=0;
while(Ti<=race_length-1)
{
//...
Possible Duplicate:
C programming : How does free know how much to free?
Hello All,
How OS will come to know how much size i have to free when we define free(pointer).
I mean we are not providing any size , only pointer to free statement.
How's internally handle the size ?
Thanks,
Neel
...
How can my client send two queries (in two different terminals) to the server at the same time? When i try it, only one works, the other closes socket.
main ()
{
readData ();
int serverFd, clientFd, clientFd2,serverLen, clientLen;
struct sockaddr_un serverAddress;/* Server address */
struct sockaddr_un clientAddress;...
Let's say I have: sample.c
int main (...) {
char str*;
get s through user input
test(str);
return 0;
}
void test (str) {
copy str to new file
change file permissions on new file
close file
}
There's no possibility of a race condition here since I have no threads in my main() method. Is that true?
...
As the Intel Manual illustrated, both Interrupt Gate and Trap Gate can be used to access a handler routine. And some exceptions even share vector numbers with interrupts. I am wondering when such a shared vector is detected by the CPU, how could CPU know whether it stands for an exception or an interrupt?
I am kind of confused about th...
Within the Windows XP Pro RGui, can't compile inline C code. Get error:
'sh' is not recognized as an internal or external command
Clearly there is a configuration error, but can't find a way to resolve it either in R documentation or via googling. Must be a simple solution!
The same R code works fine on linux: the inline C compiles ...
I have successfully created the message queue by using the following command:
msgIdHareTurtle = msgget(keyHareTurtle, 0644 | IPC_CREAT | O_NONBLOCK);
Now I want to send the queue to some other process I used,
msgsnd(msgIdHareTurtle, (struct msgbuf *)&bufHareTurtle, sizeof(int), IPC_NOWAIT);
and I try to receive it in different...
I have an algorithm that can find if a point is inside a polygon.
int CGlEngineFunctions::PointInPoly(int npts, float *xp, float *yp, float x, float y)
{
int i, j, c = 0;
for (i = 0, j = npts-1; i < npts; j = i++) {
if ((((yp[i] <= y) && (y < yp[j])) ||
((yp[j] <= y) && (y < yp[i]))) &&
(x...
Hello, I am working on a simple project in Objective-C in Xcode and I'm getting some stray/ errors about the following line of code:
if(celsius < −273.15) {
NSLog(@"It is impossible to convert temperatures less than −273.15 degrees Celsius, because this is absolute zero, the coldest possible temperature.");
}
It's actually...
I was wondering if it is feasible for me to connect this simple console program I have in objective-c into a very simple iPhone application.
Since I have no experience using Interface Builder, I'm not sure how long it would take for me to learn it.
Also, I believe my code would have to be adjusted to some iPhone APIs, rather than using...
Hi All,
I have a thread function which allocates memory using malloc(). I kill the thread using pthread_kill without freeing the dynamically allocated memory.Will it be freed automatically once i call pthread_kill or there will be a leak?
...
Hi guys,
Well.. I want to do a thing, but I don't know how searching informations to do that.
How can I send a message over the game's screen?
For example: Just writing "Hello World" on a game running in fullscreen.
I know C and C#, I'd like some tips how to do that. What a need to study etc.
Thanks,
I wait a response :)
...
what is wrong with the following code?
parseCounter1() and parseCounter1() below are two functions.
I put their pointers in const OptionValueStruct so that
they can be called accordingly when each element of option_values[]
are gone through:
typedef struct OptionValueStruct{
char counter_name[OPTION_LINE_SIZE];
int* counter_...
I noticed on windows and linux x86, float is 4bytes, double is 8, but long double is 12 and 16 on x86 and x86_64 respectively. C99 is supposed to be breaking such barriers with the specific integral sizes.
The initial technological limitation appears to be due to the x86 processor not being able to handle more than 80bit floating operat...
I am currently working on a C project that needs to be fairly portable among different building environments. The project targets POSIX-compliant systems on a hosted C environment.
One way to achieve a good degree of portability is to code under conformance to a chosen standard, but it is difficult to determine whether a given translati...
Hi,
I just had a phone interview where I was asked this question. I am aware of ways to store in register or heap or stack, but cache specifically?
...
I want to execute an untrusted .lua file in its own environment by calling lua_setfenv() so that it cannot affect any of my code.
The documentation for that function though only explains how to call a function, not how to execute a file.
Currently to run the file I use:
int error = luaL_loadfile(mState, path.c_str()) || lua_pcall(mSta...