Hi again!
I have a client and server program where I want to send an entire struct from the client and then output the struct member "ID" on the server.
I have done all the connecting etc and already managed to send a string through:
send(socket, string, string_size, 0);
So, is it possible to send a struct instead of a string throug...
I would like to do the following inside a C program on a Linux os:
Create a PIPE using a syscall (or 2)
Execute a new process using exec()
Connect the process's STDIN to to the previously created pipe.
Connect the process's output to another PIPE.
The idea is to circumvent any drive access for performance purposes.
I know that the ...
Hi,
I'm using Xcode on OSX to develop command line C applications. I would also like to use Instruments to profile and find memory leaks.
However, I couldn't find a way to display the console when launching the application from within Instruments. I'm also unable to attach to a running command line process (it exits with an error):
He...
Hi,
I wrote this function:
void r_tabs_spaces(char *input) {
int i;
for (i = 0; i < strlen(input); i++)
{
if (input[i] == ' ' || input[i] == '\t')
input[i] = '';
}
}
However when I compile this and run it, the compiler complains that "error: empty character constant" at line where...
I'm using this code to read a file into a buffer. The file is full of structs of evaluacion type (including some char and int variables).
Now I have the whole file in a buffer, how can I find the values of one variable in the buffer now?
For example buf.notamedia < 4. There are supposed to be many of them inside the file.
#include <unis...
I would like to create a portable library for iPhone, that also could be used for other platforms.
My question is the fallowing:
Does anyone knows what is the best to be used on the iPhone: Objective-C or Objective-C++? Does it works with C++ the same way as Objective-C with C or not?
Reasons: Objective-C is a superset of C, but Objec...
see the following code for yacc.
if i remove the production factor : '!' expr, the parsing conflict disappears.
what is happening here?
%{
#include <stdio.h>
#include <ctype.h>
%}
%token TRUE
%token FALSE
%%
line : line expr '\n' { printf("%d\n", $2); }
| line '\n'
|
;
expr : expr "or" term { printf("expr : expr or term\n...
I'm having a significant problem using a standard BSD-style socket in a C++ program. In the code below, I connect to a local web server, send a request, and simply create a loop waiting for data to return. I actually do receive the data, but then I get an endless stream of 0-length data as if it was a non-blocking socket. The web server ...
I am compiling my project with msvc++ 2008. I have added a reference path in project properties to ./lib, which is the directory that contains the file freeglut.lib. I have been very careful to organize everything nicely, and still msvc++ does not find the file :(. I checked the build log, to see that no where in the build command line d...
Actually i am trying to write my own printf() in c by using varags. But i am not getting the correct solution for this. can any one help me out
...
The code below shows a small 48 byte leak in valgrind.
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <unistd.h>
int main( int argc, char* argv[] )
{
Display* _display;
Window _windowHandle;
XVisualInfo* _visual;
GLXContext _context;
Atom _deleteWindowMessage;
Atom _pingWindowMessage;
_display = XOpenDi...
I'm testing code that is designed to detect when a child process has segfaulted. Imagine my surprised when this code does not always segfault:
#include <stdio.h>
int main() {
char *p = (char *)(unsigned long)0;
putchar(*p);
return 0;
}
I'm running under a Debian Linux 2.6.26 kernel; my shell is the AT&T ksh93 from the Debian k...
From command line i am getting file name which i have to compile using gcc. lets say its like this.
./a.out fileToBeCompiled.c
Then how i can compile this file using gcc within my program? lets say main.c for which a.out is being made.
...
Is there a small library for RSA or DSA without any dependencies like GMP or OpenSSL? (Written in C or Asm)
...
int i = 0;
int min = x[i];
while ( i < n ){
if ( x[i] < min ){
min = x[i];
}
i++;
}
return min;
I've written the iterative form to find the min number of an array. But I'd like to write a function that with recursion. Please help!
...
I am new to C I am trying to get comfortable with malloc + free. I have coded following test but for some reason the memory isn't freed completely (top still indicates about 150MB of memory allocated to process). Why is that?
#include <stdio.h>
#include <malloc.h>
typedef struct {
char *inner;
} structure;
int main()
{
int i;
...
Hi,
Right now I use:
char record[BUFLEN];
if(fgets(record, BUFLEN, fp) != NULL) {
/* some code */
}
to get lines from input like:
city=Boston;name=Bob;age=35
city=New York;name=Michael;age=29
Can I use something else in C that would give me not entire lines until '\n' but separate pairs like: "city=Boston" t...
I'd like to open a pipe using popen() and have non-blocking 'read' access to it.
How can I achieve this?
(The examples I found were all blocking/synchronous)
...
I use a string:
char word[100];
I add some chars to each position starting at 0.
But then I need be able to clear all those positions so that I can start add new characters starting at 0.
If I don't do that then if the second string is shorten then the first one I end up having extra characters from the first string when adding th...
I got asked this at a job interview. Here's my O(log n) solution.
Find the depth of the node.
Repeat the search, but stop at depth - n.
Is there a way to do this without the second pass?
...