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...
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 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*)...
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.