is it possible to nullify a character array which is declared inside a struct........if so show with example.......
thanks in advance
pthread
is it possible to nullify a character array which is declared inside a struct........if so show with example.......
thanks in advance
pthread
Do you have a code that nullifies array outside the struct?
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
i have a doubt..... that only am asking
Then answer is yes. Take your code for simple array. Replace it with array-member of the struct and check it. (Even no need to ask). If something will not work - post your code, decribe the problem, and ask the "smart question" ((c) FAQ)
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
If you don't know how to access structure members . . . use the . member access operator, or -> for pointers to structures.
For the "arrow" operator: (*thestruct).x is the same as thestruct->x.Code:struct s_t { int x; }; struct s_t thestruct; thestruct.x = 0;
If by "nullify a character array" you mean initialize all of its elements to zero, here is the syntax:
You can also set characters to zero with the memset() function.Code:char buffer[BUFSIZ] = {0}; struct structure_type { char buffer[BUFSIZ]; } bufstruct = { {0} };
If you just mean an empty string, then all you have to do is to set the first character to \0 or 0 like a normal string.Code:char array[BUFSIZ]; memset(array, 0, sizeof(array));
Are you doing multithreaded programming? Just curious, since your name is pthread.Code:char array[BUFSIZ]; array[0] = 0;
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
ya dwks very correct iam doing multithreading program
pthread
Threaded programming is some deep voodoo for someone who's yet to master even some rather basic C fundamentals.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.