I have a problem with the function replace. What I want to accomplish is to replace some special characters, but I haven't written the code yet. So in the replace function we can at this moment just say that the function should print line for line the way I have tried to write. Can someone please correct this function? I can’t really get...
Yesterday I was reading about debugging techniques and found Valgrind to be really interesting. It seems to use techniques from dynamic code analysis. And I followed a link from the original reference to something else called Path Profiling.
I tried Googling but I guess I am using the wrong terms to search for a good reference on these ...
I am supposed to write a program in C only. It's code for a grid follower.
I have defined a co-ordinate system of the grid (0-5,0-5). Also the bot orientations (+y,-y,+x,-x) and positions are defined. (I would welcome tips on how to write good code for this.)
Now as my bot moves through the grid and goes to some coordinate (x,y) in the...
I am writing a program in C and I am trying to create these structs.
I have three of them:
the first consisting of 2 ints and 2 chars,
the second consisting of an int and an undefined array of pointers to the first one,
and a third which contains 4 longs and 2 ints along with an undefined array of pointers to the second.
I am having ...
I am writing a udp chat application in c. I need to test if messages are received in an incorrect order. CAn anyone please tell me of a tool I can use to delay certain messages? also please tell me how to use it? thank you very much in advance! also I am using ubuntu x86_64 and OSX 10.6.4. A tool in either OS will work
...
#include <Windows.h>
#include <stdio.h>
int count = 0;
FILE* pFile = 0;
long Size = 0;
void *memfrob(void * s, size_t n)
{
char *p = (char *) s;
while (n-- > 0)
*p++ ^= 42;
return s;
}
int main()
{
fopen_s(&pFile, "***", "r+");
fseek(pFile, 0, SEEK_END);
Size = ftell(pFile);
char *...
I have a function, and I want to pass an array of char* to it, but I don't want to create a variable just for doing that, like this:
char *bar[]={"aa","bb","cc"};
foobar=foo(bar);
To get around that, I tried this:
foobar=foo({"aa","bb","cc"});
But it doesn't work. I also tried this:
foobar=foo("aa\0bb\0cc");
It compiles with a w...
Hi all, when i run the libmemcached example code on my ubuntu, it gave me the error "undefined reference to `memcached_create'", anyone can help ? thanks
#include <libmemcached/memcached.h>
int main(int argc, char **argv) {
//memcached_servers_parse (char *server_strings);
memcached_server_st *servers = NULL;
memcached_st *mem...
I am running Linux Ubuntu 10.04 and I have a Windows 7 machine and a MacBook running Mac OS X 10.6.4. How can I write a simple C program (as in NOT QT!) like:
#include <stdio.h>
int main(int argc, char **argv)
{
printf("Hello Linux and Mac and Windows!")
return 0;
}
to run on all my machines without having to compile this pro...
Possible Duplicate:
What is the rationale for fread/fwrite taking size and count as arguments?
In C, fwrite and fread take both the number of elements to write and the size of each element. It seems like just having a parameter that tells the number of bytes that should be written would more obvious and more general because th...
iOS / Objective-C: I have a large array of boolean values.
This is an inefficient way to store these values – at least eight bits are used for each element when only one is needed.
How can I optimise?
...
Hey guys,
I'm writing a program to read a file and display the number of lines and words in said file, simple stuff. What I want is to be able to run the program from terminal (running Ubuntu) by simply typing:
count
But I'm not sure how to get the filename into a variable in the C program. Little help please?
Thanks in advance.
...
In php/perl we can simply say $a='hi" and then $a=1 without needing to declare its type. But there are type casting errors in java for the same.
Why this difference?
...
#define one 0
#ifdef one
printf("one is defined ");
#ifndef one
printf("one is not defined ");
In this what is the role of #ifdef and #ifndef, and what's the output?
...
If I try something such as:
int anint;
char achar;
printf("\nEnter any integer:");
scanf("%d", &anint);
printf("\nEnter any character:");
scanf("%c", &achar);
printf("\nHello\n");
printf("\nThe integer entered is %d\n", anint);
printf("\nThe char entered is %c\n", achar);
It allows entering an integer, then skips the second scanf com...
Why can't we declare a static variable within a structure in the C programming language?
...
I am looking for sample code in C which reads Lua command line arguments.
Any help?
...
I have to make a multiplayer game and give the users(on different) an option to change their screen resolution in order to sustain their hardware requirements.Similar to counterstrike.
How can I implement this in c ? how can I give the users sitting on different computers an option to change their screen resolution ?
...
Hi,
I have three gyroscope values, pitch, roll and yaw. I would like to add Kalman filter to get more accurate values. I found the opencv library, which implements a Kalman filter, but I can't understand it how is it really work.
Could you give me any help which can help me? I didn't find any related topics on the internet.
I tried to ...
Godday all.
Could someone please explain the logical difference in these two implementations of a byte-reversing function.
Example 1:
uint32_t byte_reverse_32(uint32_t num) {
static union bytes {
uint8_t b[4];
uint32_t n;
} bytes;
bytes.n = num;
uint32_t ret = 0;
ret |= bytes.b[0] << 24;
ret |=...