I have a stucture of arrays that holds data such as member number, videonumber,and rental date.
How would i go about deleting from the structure one of these records?
BlueBob
I have a stucture of arrays that holds data such as member number, videonumber,and rental date.
How would i go about deleting from the structure one of these records?
BlueBob
Highlight the line that the member is declared on and hit the delete key. You can't delete a structure member at runtime, you can only clear the values that the member holds.
-Prelude
My best code is written with the delete key.
prelude is right...
but if i'll try to analyze you problem, i think you want to
delete tha value in those member variables
the problem with you is that you did not specify your structure
so take a look at this
struct name{
char employee[80];
int sex;
}age;
main(){
age.employee[0]=NULL;
age.sex=0;
}
i am not quite sure if this is ok with the other guys from this board..
" programming is 1% syntax and 99% logic "
>age.employee[0]=NULL;
This is the only part that chafes with me. Despite what some may tell you, NULL and NUL are not interchangeable. So if you want to clear the array by making everying inaccessable to string based functions, this would be better:
age.employee[0] = '\0';
Though if you want to clear the entire array, memset would be your best bet:
memset ( age.employee, '\0', 80 );
-Prelude
My best code is written with the delete key.
see i told you, this guys are really cool
they always have the best idea...
this site is the best site so far as far as c is concern
to bluebob
next time, read what you ask so that you'll get the right answer..
tnx
" programming is 1% syntax and 99% logic "
MSVC++ does not recognize the keyword 'NUL'. The decimal value of 'NULL' is zero. It's the same thing as doing:Originally posted by Prelude
>age.employee[0]=NULL;
This is the only part that chafes with me. Despite what some may tell you, NULL and NUL are not interchangeable. So if you want to clear the array by making everying inaccessable to string based functions, this would be better:
age.employee[0] = '\0';
-Prelude
age.employee[0] = 0;
In either case, your compiler treats 'NULL' as 0 and the end result is the same. There is no standard definition of the word 'NUL' in C. This is an ASCII definition if I recall correctly. NULL is commonly defined as '\0'. Again, this has the same decimal value as 0.
However, I see the point you are trying to make.
Quzah.
Hope is the first step on the road to disappointment.
>MSVC++ does not recognize the keyword 'NUL'.
I don't know of any others that do, I imagine it would be too confusing to have a one L nul and a two L null used in similar contexts.
>The decimal value of 'NULL' is zero.
Only in some cases, here is a snip from stdio.h for MSVC++
>In either case, your compiler treats 'NULL' as 0 and the end result is the same./* Define NULL pointer value */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
Once again, not always and you can't be sure. So it's better to only use NULL for pointers and to specify '\0' explicitly or define it for a nul.
>This is an ASCII definition if I recall correctly.
Yes, NUL is 0x00(hex) or 00(oct) in the ASCII table.
>NULL is commonly defined as '\0'. Again, this has the same decimal value as 0.
In this case I believe you're wrong, the standard headers that I've seen are all similar to the one I quoted above. While I can agree with you to some extent that NULL is defined as 0, it's in such a way that you still should be very wary of using it as a simple decimal value.
>However, I see the point you are trying to make.
-Prelude
My best code is written with the delete key.
I am re reading "The C++ Lang by Bjarne Stroustrup" And he actually recomends not to use NULL at all unless you define it yourself. He recomends to always use 0.