Hi
Could someone please help with this? I have the following:
// part_1
if (pthread_create(&threadID, NULL, ThreadMain,
(void *) clientSocket) != 0) {
cerr << "Unable to create thread" << endl;
exit(1);
}
// part_2
void *ThreadMain(void *clientSocket) {
pthread_detach(pthread_self());
...
delete (TCPSocket *) c...
hi
Could someone please tell me if this is possible in C or C++?
void fun_a();
//int fun_b();
...
main(){
...
fun_a();
...
int fun_b(){
...
}
...
}
or something similar, as e.g. a class inside a function?
thanks for your replies,
...
I need to implement qsort in C and sort in reverse lexicographical order. I'm confused on how to create and call the comparison function. This is what I have so far..
qsort (strArr, numLines, sizeof(char*) , sort);
int sort(const void * str1, const void * str2) {
return (-1) * strcasecmp((char*) str1, (char*) str2);
};
Eclipse is te...
How to create a directory with C code (other than the method of forking and using mkdir) ? Is there anything like dirent.h? dirent.h only allows to read directories. (without using external library)
...
Possible Duplicate:
Delete folder with items
How to delete a non empty directory in C or C++? Is there any function? rmdir only deletes empty directory. Please provide a way without using any external library.
Also tell me how to delete a file in C or C++?
...
I'm writing a small program with the OpenSSL library that is suppose to establish a connection with an SSLv3 server. This server dispenses a self-signed certificate, which causes the handshake to fail with this message: "sslv3 alert handshake failure, self signed certificate in certificate chain."
Is there a way I can force the connecti...
I am calculating g with e and s, which are all doubles. After that I want to cut off all digits after the second and save the result in x, for example:
g = 2.123 => x = 2.12
g = 5.34995 => x = 5.34
and so on. I Use...
g = 0.5*e + 0.5*s;
x = floor(g*100)/100;
...and it works fine most of the time. But sometimes I get strange results...
I am using VC++ 2008 express edition for C. When I try to run this:
/* Demonstrates printer output. */
#include <stdio.h>
main()
{
float f = 2.0134;
fprintf(stdprn, "This message is printed.\n\n");
fprintf(stdprn, "And now some numbers:\n\n");
fprintf(stdprn, "The square of %f is %f.", f, f*f);
/* Send a form feed */
fprintf...
Hey Guys
My aim is to write an app which generates an char - array (each should be random-filled with strings of the length 4) and sorts this array. The time this process takes should be measured. I coded the following:
#include <string.h>
#include <jni.h>
#include <time.h>
#include <math.h>
clock_t start, finish;
static int ARRAY_LEN...
How the memory management unit(MMU) detects the double free of a pointer?
I know that its a good practice to make the pointer NULL just after freeing it, but suppose programmer does not do it. Is there any MMU mechanism to detect it?
...
C-strings are null-terminated which means that in a char-array, the char at index strlen() is a byte with all bits set to 0. I've seen code where, instead of '\0', the integer 0 is used. But since sizeof(int) > sizeof(char), this might actually write beyond the allocated space for the array - am I wrong? Or does the compiler implicitely ...
I am having trouble understanding how to assign memory
to a double pointer.
I want to read an array of strings and store it.
char **ptr;
fp=fopen("file.txt","r");
ptr=(char**)malloc(sizeof(char*)*50);
for(int i=0;i<20;i++)
{
ptr[i]=(char*)malloc(sizeof(char)*50);
fgets(ptr[i],50,fp);
}
instead of thi...
I am implementing a stack and while it was a no-brainer to implement the basic operations push and pop, I am wondering how to implement somewhat efficient searching. The underlying structure is a linked list
...
Hi,
I have come across a very odd problem in C that I have never encountered before. I have narrowed it down to the following very simple snippet.
The variables are global and of type:
int cpd;
int nPart;
And here is the relevant code snippet which I gradually stripped down to the very minimum needed to produce the issue:
...
Why does this code produce the warning?
FILE* my_open_file(char* filename)
{
FILE* fp=fopen(filename,"r");
if(fp==NULL)
{
perror("Error opening file");
return -1;
}
return fp;
}
asdf.c: In function ‘my_open_file’:
asdf.c:9: warning: return makes
pointer from integer without a cast
fp is already a pointer, ...
What is "stack thrash"? Or "a stack thrash"? (Since I don't know the definition I'm not sure if it is a countable or uncountable term.)
...
I read the documentation and it says that a long is %li but the print out comes back as -2147024891. What gives?
...
Hi, i'm a little stuck on getting a plugin to work. I need it to take a "src" parameter but I can't seem to make it do this.
So i've basically got the npsimple basic plugin.
It's probably something really silly i'm missing
Joe
...
I need to MPI_Gatherv() a number of int/string pairs. Let's say each pair looks like this:
struct Pair {
int x;
unsigned s_len;
char s[1]; // variable-length string of s_len chars
};
How to define an appropriate MPI datatype for Pair?
...
Hello
I can't truly understand why the free process returns in an error. I got this code in C:
int LuffarschackStart(void)
{
/* to avoid the program from closing */
char readEnd;
int i = 0;
board_type *board = malloc(sizeof(square_type));
if (board == NULL)
{
printf("Could not allocate the memory needed...");
scanf("%c", &...