I am writing a multithreaded 'chatroom' style server that constantly broadcasts the messages it receives to all the clients so that they can watch the discussion unfold. Upon a client's successful connection to the server, the client creates a new thread. From inside this thread I would like...
If you need to dynamically allocate the multidimensional arrays, try:
#include <memory.h>
#include <string.h>
#define DIM_ONE_SIZE 10
#define DIM_TWO_SIZE 256
int main(){
int i;
//Allocate dimension one
char** multiDimArray =
calloc (DIM_ONE_SIZE, sizeof(char*))...
I was under the impression that one shouldn't return pointers to variables that are created inside of a function, unless the variable was static or allocated on the heap. Why does the following code work fine ? In foo1() since
str points to a string-literal, I guess the string-literal is...
What can one do if they need to pass an ADT to a function and all they have is a pointer to the ADT ? For example:
int main(){
MYTYPE* a = createInstance();
//Call func: doSomething( ??? )
/*
...with a as the argument.
In other words, dereference the pointer to...
I'll give you the benefit of the doubt and assume that you misunderstood the question... All I'm asking for are some project suggestions that others may have found insightful to sharpen my understanding of the subtle areas of the C programming language... I have a very strong understanding of...
I have a B.A/M.S. in compsci, and one year of professional programming experience... The issue is that most of the development at my last job was in a proprietary scripting language (which was a supremely crippled version of C). Anyhow, I've written many programs in various languages throughout...
I've seen 'lots' of C code that explicitly casts the ptr returned by malloc, yet I hear that this is not always necessary. Just when is it necessary (if ever) ? Does the situation differ between C and C++ (even though you'd probably use 'new' in C++) ?
MYTYPE* a = (MYTYPE*)...
That'll do it, I was not aware of the strsep() function.
In this case, suppose the data is coming straight from a DB table dump... I'm sure that 'many' programs have been written in C to parse this kind of information... Can you suggest a more elegant solution that performs the necessary error...
Suppose I am reading in the following text file, I would like to properly handle missing data between the #-delims when reading.
#mike#tyson#11898
#carl#lopez#98878
#vincent##11212
#utah#smith#
...
typedef struct{
char* field1;
char* field2;
int field3;
} CUSTOMER;
int main(){...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.