473,396 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

c equivalence of const_cast?

I'm trying to convert some small piece of c++ code to c, only to ease
linking it to a third language (I'm not knowledgeable in either c or
c++).

What would be the the c equivalence of:
lpData=const_cast<char*>(Something);

Trying to compile this with gcc 3.2.3 (mingw special 20030504-1)

Thanks!
Björn
Nov 14 '05 #1
26 20896
i'm not a c++ guru, but i think you should be able to do:
lpData=(const char*)something;

Nov 14 '05 #2
"Mike Deskevich" <mi***********@gmail.com> writes:
i'm not a c++ guru, but i think you should be able to do:
lpData=(const char*)something;


Actually, I think he wants
lpData = (char*)something;

<OT>
A C++ const_cast is used to cast away constness. C++ has several
flavors of casts that are more restricted than C's "Just convert it,
trust me, I know what I'm doing" cast. (C++ has C-style casts as
well.)
</OT>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #3
"Bj?rn" <ss*****@hotmail.com> wrote in message
news:d5*************************@posting.google.co m...
I'm trying to convert some small piece of c++ code to c, only to ease
linking it to a third language (I'm not knowledgeable in either c or
c++).

What would be the the c equivalence of:
lpData=const_cast<char*>(Something);


lpData = (char*)Something;

(C doesn't have different 'flavors' of casts as does C++.)

-Mike
Nov 14 '05 #4
ss*****@hotmail.com (Bj?rn) wrote:
I'm trying to convert some small piece of c++ code to c, only to ease
linking it to a third language (I'm not knowledgeable in either c or
c++).

What would be the the c equivalence of:
lpData=const_cast<char*>(Something);


lpData = (char *)Something;

Same goes for all the other C++ cast keywords
Nov 14 '05 #5
lpData = (char*) (Something);
Nov 14 '05 #6
ss*****@hotmail.com (Bj?rn) writes:
I'm trying to convert some small piece of c++ code to c, only to ease
linking it to a third language (I'm not knowledgeable in either c or
c++).
In C doesn't exsist a const keyword, normally, some compiler support
const variables, like gcc, but IMHO it is the best way to remove the
const from the source, and replace it with defines.
What would be the the c equivalence of:
lpData=const_cast<char*>(Something);
If you have done the thing described above just remove the
const_cast<char*> statement, and assign Something to lpData:

lpData = Something;
Trying to compile this with gcc 3.2.3 (mingw special 20030504-1)


Thats because gcc supports (in C - Mode) const but not the C++
const_cast<..>

HTH && Kind regrads
icolas
--
| Nicolas Pavlidis | Elvis Presly: |\ |__ |
| Student of SE & KM | "Into the goto" | \|__| |
| pa****@sbox.tugraz.at | ICQ #320057056 | |
|-------------------University of Technology, Graz----------------|
Nov 14 '05 #7
Nicolas Pavlidis <pa****@sbox.tugraz.at> writes:
ss*****@hotmail.com (Bj?rn) writes:
I'm trying to convert some small piece of c++ code to c, only to ease
linking it to a third language (I'm not knowledgeable in either c or
c++).


In C doesn't exsist a const keyword, normally, some compiler support
const variables, like gcc, but IMHO it is the best way to remove the
const from the source, and replace it with defines.


C certainly does have a "const" keyword (though it doesn't have
"const_cast").

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #8
Nicolas Pavlidis wrote:
ss*****@hotmail.com (Bj?rn) writes:
I'm trying to convert some small piece of c++ code to c, only to
ease linking it to a third language (I'm not knowledgeable in
either c or c++).


In C doesn't exsist a const keyword, normally, some compiler
support const variables, like gcc, but IMHO it is the best way to
remove the const from the source, and replace it with defines.
What would be the the c equivalence of:
lpData=const_cast<char*>(Something);


If you have done the thing described above just remove the
const_cast<char*> statement, and assign Something to lpData:

lpData = Something;
Trying to compile this with gcc 3.2.3 (mingw special 20030504-1)


Thats because gcc supports (in C - Mode) const but not the C++
const_cast<..>


Before supplying flawed advice, I suggest you at least read the
other replies to this enquiry, some of which were quite accurate.

--
"I support the Red Sox and any team that beats the Yankees"

"Any baby snookums can be a Yankee fan, it takes real moral
fiber to be a Red Sox fan"
Nov 14 '05 #9
Thank you for all your suggestions. Coming from Ada language I'm
always quite surprised of how easy it often is to type cast in C, good
or bad.

Björn
Nov 14 '05 #10
ss*****@hotmail.com (Bj?rn) writes:
Thank you for all your suggestions. Coming from Ada language I'm
always quite surprised of how easy it often is to type cast in C, good
or bad.


All type casts are explicit in C. I don't see how that's "easy"
or "hard", it's just a matter of typing.
--
"Some people *are* arrogant, and others read the FAQ."
--Chris Dollin
Nov 14 '05 #11
Keith Thompson <ks***@mib.org> writes:
Nicolas Pavlidis <pa****@sbox.tugraz.at> writes:
ss*****@hotmail.com (Bj?rn) writes:
I'm trying to convert some small piece of c++ code to c, only to ease
linking it to a third language (I'm not knowledgeable in either c or
c++).


In C doesn't exsist a const keyword, normally, some compiler support
const variables, like gcc, but IMHO it is the best way to remove the
const from the source, and replace it with defines.


C certainly does have a "const" keyword (though it doesn't have
"const_cast").


Maybe I'm wrong, but AFAIK const is not supported by C89, if I'm wrong
tell me! So I recommended to use #defines instead of const becaue
support of C99 is not the best one with some compilers...

Kind regrads,
Nicolas
--
| Nicolas Pavlidis | Elvis Presly: |\ |__ |
| Student of SE & KM | "Into the goto" | \|__| |
| pa****@sbox.tugraz.at | ICQ #320057056 | |
|-------------------University of Technology, Graz----------------|
Nov 14 '05 #12
Ben Pfaff <bl*@cs.stanford.edu> writes:
ss*****@hotmail.com (Bj?rn) writes:
Thank you for all your suggestions. Coming from Ada language I'm
always quite surprised of how easy it often is to type cast in C, good
or bad.


All type casts are explicit in C. I don't see how that's "easy"
or "hard", it's just a matter of typing.


Part of the previous poster's surprise may have to do with a confusion
between casts and conversions. A cast is a syntactic construct that
looks like:
(type_name)expression
and specifies a conversion. There is no such thing as an implicit
cast. A conversion is an operation that happens at run time (or it
might happen during compilation if the optimizer is clever).

It's all too common to misuse the term "cast" or "type cast" to refer
to conversions rather than to the syntactic construct.

<OT>
Compared to Ada, C has far more cases of implicit conversions. In C,
you can convert any numeric type to any other numeric type just by
assigning the value; Ada requires such conversions to be done
explicitly. C also allows explicit conversions in more cases;
conversions between incompatible pointer types (that can lead to
undefined behavior in C) aren't allowed in Ada. Ada does have a type
punning mechanism called Unchecked_Conversion (often needed for
systems-level programming).
</OT>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #13
Nicolas Pavlidis <pa****@sbox.tugraz.at> writes:
Keith Thompson <ks***@mib.org> writes:
Nicolas Pavlidis <pa****@sbox.tugraz.at> writes:
> ss*****@hotmail.com (Bj?rn) writes:
>> I'm trying to convert some small piece of c++ code to c, only to ease
>> linking it to a third language (I'm not knowledgeable in either c or
>> c++).
>
> In C doesn't exsist a const keyword, normally, some compiler support
> const variables, like gcc, but IMHO it is the best way to remove the
> const from the source, and replace it with defines.


C certainly does have a "const" keyword (though it doesn't have
"const_cast").


Maybe I'm wrong, but AFAIK const is not supported by C89, if I'm wrong
tell me!


You are wrong. C89 includes const.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Nov 14 '05 #14
In article <2t*************@uni-berlin.de>,
Nicolas Pavlidis <pa****@sbox.tugraz.at> wrote:
Keith Thompson <ks***@mib.org> writes:
Nicolas Pavlidis <pa****@sbox.tugraz.at> writes:
ss*****@hotmail.com (Bj?rn) writes:
> I'm trying to convert some small piece of c++ code to c, only to ease
> linking it to a third language (I'm not knowledgeable in either c or
> c++).

In C doesn't exsist a const keyword, normally, some compiler support
const variables, like gcc, but IMHO it is the best way to remove the
const from the source, and replace it with defines.


C certainly does have a "const" keyword (though it doesn't have
"const_cast").


Maybe I'm wrong, but AFAIK const is not supported by C89, if I'm wrong
tell me! So I recommended to use #defines instead of const becaue
support of C99 is not the best one with some compilers...


Check your K&R 2nd edition. "const" was added as part of ANSI C -- i.e.
C89. It's even mentioned in the "changes from K&R C" appendix.

I think writing new code to be backwards compatible with pre-ANSI C
compilers is a bit silly nowadays.

Cheers,
- jonathan
Nov 14 '05 #15
On Mon, 18 Oct 2004 10:45:34 -0700, in comp.lang.c , Ben Pfaff
<bl*@cs.stanford.edu> wrote:
ss*****@hotmail.com (Bj?rn) writes:
Thank you for all your suggestions. Coming from Ada language I'm
always quite surprised of how easy it often is to type cast in C, good
or bad.


All type casts are explicit in C. I don't see how that's "easy"
or "hard", it's just a matter of typing.


compared to C++, where the compiler tends to fight you every step of the
way, in C the compiler tends to treat casts as The Word From The
Mountain.... which is of course what makes them tricky.....

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #16
On 18 Oct 2004 20:34:44 +0200, in comp.lang.c , Nicolas Pavlidis
<pa****@sbox.tugraz.at> wrote:
Maybe I'm wrong, but AFAIK const is not supported by C89, if I'm wrong
tell me!
You're wrong. It just isn't the same keyword as in C++, which probably
confuses some people.
So I recommended to use #defines instead of const


#defines are (in C) totally different to consts. I do agree tho that tehy
behave more like C++'s const objects.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #17
Mark McIntyre <ma**********@spamcop.net> writes:
On 18 Oct 2004 20:34:44 +0200, in comp.lang.c , Nicolas Pavlidis
<pa****@sbox.tugraz.at> wrote:
Maybe I'm wrong, but AFAIK const is not supported by C89, if I'm wrong
tell me!


You're wrong. It just isn't the same keyword as in C++, which probably
confuses some people.


It isn't? `const' has largely the same meaning in C and in C++
as far as I know. There are some differences in which
conversions that change const-ness are allowed implicitly.
--
Bite me! said C.
Nov 14 '05 #18
On 18 Oct 2004 20:34:44 +0200, in comp.lang.c , Nicolas Pavlidis
<pa****@sbox.tugraz.at> wrote:
Maybe I'm wrong, but AFAIK const is not supported by C89, if I'm wrong
tell me!
You're wrong. It just isn't the same keyword as in C++, which probably
confuses some people.
So I recommended to use #defines instead of const


#defines are (in C) totally different to consts. I do agree tho that tehy
behave more like C++'s const objects.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #19
>Mark McIntyre <ma**********@spamcop.net> writes:
[const] just isn't the same keyword as in C++, which probably
confuses some people.

In article <news:87************@benpfaff.org>
Ben Pfaff <bl*@cs.stanford.edu> wrote:It isn't? `const' has largely the same meaning in C and in C++
as far as I know. There are some differences in which
conversions that change const-ness are allowed implicitly.


There are two other semantic differences I would consider
significant enough to mention:

- C++'s "const" declares actual constants by default, and
- the default linkage of C++ "const" identifiers is different.

(These two are related, unsurprisingly -- "extern const" in C++
means what "const" does in C if the variable is not initialized.
If the variable *is* initialized, though, the C++ "const" is
still a constant.)

In particular, the following is invalid in C:

const int N = 10;
int a[N];
int main(void) {
/* ... code using the array "a" ... */
return 0;
}

but valid in C++ (because N is not a constant in C, but is in C++):

% cc -o t t.c
t.c:2: variable-size type declared outside of any function
% g++ -o t++ -x c++ t.c
% ./t++
% echo $status [examines the value returned from main()]
0
%
Contrariwise, the following works as C but not as C++:

/* file1.c */
const int N = 10; /* note lack of "extern" */
int f2(void);
int main(void) {
return f2();
}

/* file2.c -- a separate translation unit */
#include <stdio.h>
#include <stdlib.h>

extern const int N;

int f2(void) {
int i, *p, ret;

printf("N is %d (we assume it is at least 1)\n", N);
p = (int *)malloc(N * sizeof *p); /* cast required for C++ */
p[0] = 42;
for (i = 1; i < N; i++)
p[i] = p[0] * (5 - i);
ret = !p[N - 1];
free(p);
return ret;
}

Here, in C, N is shared across the two translation units, but in
C++ file2.c's extern "N" is missing:

% cc -o c file[12].c
% ./c
N is 10 (we assume it is at least 1)
% echo $status
0
% g++ -o c++ -x c++ file[12].c
/tmp/ccg7oeo1.o: In function `f2(void)':
/tmp/ccg7oeo1.o(.text+0xc): undefined reference to `N'
/tmp/ccg7oeo1.o(.text+0x22): undefined reference to `N'
/tmp/ccg7oeo1.o(.text+0x55): undefined reference to `N'
/tmp/ccg7oeo1.o(.text+0x88): undefined reference to `N'
%
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 14 '05 #20
Chris Torek <no****@torek.net> writes:
In article <news:87************@benpfaff.org>
Ben Pfaff <bl*@cs.stanford.edu> wrote:
`const' has largely the same meaning in C and in C++
as far as I know. There are some differences in which
conversions that change const-ness are allowed implicitly.


There are two other semantic differences I would consider
significant enough to mention:

- C++'s "const" declares actual constants by default, and
- the default linkage of C++ "const" identifiers is different.


Oh, yes, I temporarily forgot about those. Thank you for
reminding me.
--
"Some people *are* arrogant, and others read the FAQ."
--Chris Dollin
Nov 14 '05 #21
Nicolas Pavlidis <pa****@sbox.tugraz.at> wrote:
ss*****@hotmail.com (Bj?rn) writes:
I'm trying to convert some small piece of c++ code to c, only to ease
linking it to a third language (I'm not knowledgeable in either c or
c++).
In C doesn't exsist a const keyword


If you mean "the const keyword doesn't exist in C" then you're
wrong (otherwise, I don't know what you were trying to say).
See N869 6.4.1#1 (the list of keywords). I don't have a copy
of C89 so I can't give you a reference to that, but read
K&R2 if you have it.
normally, some compiler support const variables, like gcc,
Compilers must support it
but IMHO it is the best way to remove the const from the source,
and replace it with defines.


Many people argue the opposite (defines circumvent scope and
linkage rules and type-checking). See the thread "What Value
is Offered by Const-Correctness" in c.l.c++ at the moment,
much of it applies to both languages.

Anyway, how would you use a define to avoid the OP's problem,
which was something like:

int some_func(char *ptr); /* does not modify ptr */
char const *other_func(void);

void foo()
{
char *ptr = other_func();
some_func(ptr);
}
Nov 14 '05 #22
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chris Torek wrote:
|>Mark McIntyre <ma**********@spamcop.net> writes:
|>
|>>[const] just isn't the same keyword as in C++, which probably
|>>confuses some people.
|
|
| In article <news:87************@benpfaff.org>
| Ben Pfaff <bl*@cs.stanford.edu> wrote:
|
|>It isn't? `const' has largely the same meaning in C and in C++
|>as far as I know. There are some differences in which
|>conversions that change const-ness are allowed implicitly.
|
|
| There are two other semantic differences I would consider
| significant enough to mention:
|
| - C++'s "const" declares actual constants by default, and
| - the default linkage of C++ "const" identifiers is different.
|
| (These two are related, unsurprisingly -- "extern const" in C++
| means what "const" does in C if the variable is not initialized.
| If the variable *is* initialized, though, the C++ "const" is
| still a constant.)
|
| In particular, the following is invalid in C:

Is it still invalid under C99, with VLAs? (I understand that `C'
defaults to C89/C90, but this could possibly confuse someone who
actually had a C99 compiler.)

|
| const int N = 10;
| int a[N];
| int main(void) {
| /* ... code using the array "a" ... */
| return 0;
| }
|

~From what I read of the post you snipped, it seems that Nicloas Pavlidis
should say that `const'-ness in C isn't as strong as it is in C++ or
Pascal or Ada, for example, and that if he wants to avoid /all/
potential surprises arising from the different semantics, he should use
`#define's in C where he would use constant variables in Ada.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBdGd3KxatjOtX+j0RAruSAJ91WVoe4BPg5iQuffAQ5R GyX7uC9wCfQaWo
ftLqRdBJYjOk3NG3XpvXgGM=
=kr6o
-----END PGP SIGNATURE-----
Nov 14 '05 #23

"Nicolas Pavlidis" <pa****@sbox.tugraz.at> wrote in message
news:2t*************@uni-berlin.de...

Maybe I'm wrong, but AFAIK const is not supported by C89, if I'm wrong
tell me!


You're wrong. See 3.1.1 and 3.5.3

-Mike
Nov 14 '05 #24
Chris Barts <ch************@gmail.com> writes:
Chris Torek wrote: [...] | In particular, the following is invalid in C:

Is it still invalid under C99, with VLAs? (I understand that `C'
defaults to C89/C90, but this could possibly confuse someone who
actually had a C99 compiler.)

|
| const int N = 10;
| int a[N];
| int main(void) {
| /* ... code using the array "a" ... */
| return 0;
| }
|


A C99 variable length array cannot have static storage duration
(C99 6.7.5.2p2).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #25
On 18 Oct 2004 20:34:44 +0200, in comp.lang.c , Nicolas Pavlidis
<pa****@sbox.tugraz.at> wrote:
Maybe I'm wrong, but AFAIK const is not supported by C89, if I'm wrong
tell me!
You're wrong. It just isn't the same keyword as in C++, which probably
confuses some people.
So I recommended to use #defines instead of const


#defines are (in C) totally different to consts. I do agree tho that tehy
behave more like C++'s const objects.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #26
On Mon, 18 Oct 2004 13:00:00 -0700, in comp.lang.c , Ben Pfaff
<bl*@cs.stanford.edu> wrote:
Mark McIntyre <ma**********@spamcop.net> writes:
On 18 Oct 2004 20:34:44 +0200, in comp.lang.c , Nicolas Pavlidis
<pa****@sbox.tugraz.at> wrote:
Maybe I'm wrong, but AFAIK const is not supported by C89, if I'm wrong
tell me!


You're wrong. It just isn't the same keyword as in C++, which probably
confuses some people.


It isn't? `const' has largely the same meaning in C and in C++
as far as I know.


C++ consts are actually constants. Whereas C's const objects are merely
advisory.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #27

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Xah Lee | last post by:
another functional exercise with lists. Here's the perl documentation. I'll post a perl and the translated python version in 48 hours. =pod parti(aList, equalFunc) given a list aList of...
3
by: drowned | last post by:
all right, check it out... I've got a practice exercise from "thinking in c++" whose answer isn't covered in the annotated solutions guide, so I'm trying to handle it, but I don't understand what...
7
by: R. Anbeeswaran | last post by:
Hi All, void main() { const int i = 20; int *p = const_cast<int*>(&i); *p = 40; cout <<"i="<< i <<"\t"<<"*p="<<*p<<"\n"; }
4
by: S.Senthilvel | last post by:
hi, I am a little confused about the const_cast.I've thought it this way till now. //Proper cast int i = 10; const int* pci = &i; int *pi = const_cast<int*>(pci);
18
by: johny smith | last post by:
Can someone please give me some good reference site/information for understanding when and why I would use 1.) const_cast Don't know why you would do this? 2.) reinterpret_cast. I have used...
6
by: AlesD | last post by:
Hello, I can't figure out how to build assignment operator for class which contains "type* const value". --- example --- class parent_t; class child_t {
20
by: CoolPint | last post by:
While I was reading about const_cast, I got curious and wanted to know if I could modify a constant variable through a pointer which has been "const_cast"ed. Since the pointer would be pointing to...
6
by: Simon Bailey | last post by:
In the following code at the end of the program z = 20 & y = 99. void doit(const int* x) { int* nonconst; nonconst = const_cast<int*>(x); *nonconst = 99; } int main(int argc, char* argv)
6
by: Alexander Stippler | last post by:
Hello, I wonder if and in what cases casting const away by a const_cast can be dangerous. In one place the only way I can imagine to realize a pretty nice feature is casting away const. Now I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.