|
From: Ioannis V. <no...@ya...> - 2001-10-22 19:39:30
|
> -----Original Message----- > From: KJK::Hyperion [mailto:no...@li...]=20 > Sent: Monday, October 22, 2001 6:08 PM > To: Ioannis Vranos > Subject: RE: [Dev-C++] Errorhandling > > only in C code or C-minded C++ code. In C++ you use one of=20 > the countless=20 > string classes and you're done, they allow embedded nulls and=20 > whatsoever=20 > since they generally have a length field. Heck, even OLE's=20 > BSTR does, and=20 > it's a plain struct Now all these are details but we must clear details. :) Yes i strongly agree with you, in C++ code we should use standard library object and containers not low level (dangerous) C stuff. >=20 > Even in the case, it MAY at most cause memory leaks (strlen=20 > returns less=20 > chars than actually allocated), but only if the compiler=20 At most it can cause anything depending on how our code thinks on doing things. We could depend on sizeof to get the length of the string (wrong approach), write some code performing for example binary search with the possibility to encounter the last '\0; instead of the first, and this because we assume the string has only one '\0'. The ways to screw up are infinite. :) The most important thing to think is that we must not use the form "string\0". :) > allocates string=20 > literals as variants, something it SHOULDN'T do (string=20 > literals SHOULD be=20 > considered constants). Else the incriminated strings remain=20 We were talking about C stuff ( strcat(buffer, "string\0"); where our "string\0" would be added to string stored in buffer. String literals of course must not be dealt as variables. > exactly the=20 > same, untouched, and the extra null is ignored >=20 In case of strcat() operatios the extra null is ignored but i am talking for troubles in general. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys |
|
From: Ioannis V. <no...@ya...> - 2001-10-23 08:45:44
|
Uf. I do not want to open issues here, but there are many searching algorithms (which i do not know). One efficient the C library provides is bsearch(). Of course this particulal algorithm isn't applicable here, but the point is that any implementation can provide its own strcat() version. It can be written in assembly, pascal (as in C++ Builder) with a C type interface, e.t.c.. It is only guaranteed that it doesn't miss the first appearance of '\0'. Of course it can be written in C looking character after character. :) Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys > -----Original Message----- > From: Juliet [mailto:no...@li...]=20 > Sent: Monday, October 22, 2001 8:28 PM > To: Ioannis Vranos > Subject: RE: [Dev-C++] Errorhandling >=20 >=20 > At 00.54 21/10/2001 +0200, you wrote: > >That doesn't mean that strcat() searches character by=20 > character for 0=20 > >but > >it *behaves* as if it does that. >=20 > Post-scriptum to my previous message: well, it DOES. It's the=20 > only way to=20 > do it, you just have to write it in the most efficient way.=20 > Look at this=20 > (strcat.c, from ReactOS msvcrt implementation): >=20 > /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details=20 > */ #include <msvcrt/string.h> >=20 > char * > strcat(char *s, const char *append) > { > char *save =3D s; >=20 > for (; *s; ++s); > while ((*s++ =3D *append++)); > return save; > } >=20 |
|
From: Ioannis V. <no...@ya...> - 2001-10-24 20:46:51
|
> -----Original Message----- > From: Juliet [mailto:no...@li...]=20 > Sent: Wednesday, October 24, 2001 9:15 PM > To: Ioannis Vranos > Subject: RE: [Dev-C++] Errorhandling >=20 >=20 > At 11.47 23/10/2001 +0200, you wrote: > >Uf. I do not want to open issues here, but there are many searching > >algorithms (which i do not know). One efficient the C=20 > library provides is=20 > >bsearch(). >=20 > That would be overkill in this case :) Think about it, what=20 > does strcat do?=20 > it finds the end of the first string, then starts copying the=20 > second string=20 > into it, until that string ends too. You'd be right if the=20 > EOS wasn't a=20 > single character but rather some character sequence, hopefully the C=20 > designers weren't that stupid :) I am not talking about strcat(). I am talking in general stating that "string\0" only bad things can cause (except we need that particular form and we know what we are doing). Because the person who writes "string\0" doesn't seem to know that "string" has a '\0' automatically. Anyway the implementation of strcat() would be enough stupid if it searched character after character (even if it was written in C itself). Many compiler operations are written in very much low level and system dependent way so we can't know how exactly strcat() is written (with the exception we have the source code). For example see 8.7 in K&R. Also see header files of Dev-C++ to see Windows dependent declarations even there. The only thing we know is that strcat() must replace the first '\0' it finds so thinking of it looking character after character doesn't cause any harm. >=20 > >It can be written in assembly, pascal (as in C++ Builder)=20 > with a C type > >interface, e.t.c.. >=20 > Generally a language's runtime is written in the same language, for=20 > essentially one reason: developers willing to learn from it=20 > and improve it=20 > won't need extra tools, compilers or knowledge of foreign=20 > languages. In=20 > particular, using ASM is the worst thing you could do It is not necessary to have the source code of the implementation of the library. It may come in precompiled form and only the header files with the declarations to be supplied. It is also possible to not even have any source files at all, and #include statements to work as switches as i mentioned some day (but the #include mechanism *must* behave as if there are source files and are included, the same it does with our header files). So it is safe to always think that #include includes header files even if this is not the case. >=20 > You *need* ASM only to use features of the particular architecture=20 > (interrupts/traps, instructions implementing whole functions,=20 > native large=20 > integers, native floats, etc.), not covered by normal=20 > languages (exactly=20 > because of their specificity). The speed/optimization thing=20 > should be left=20 > to the compilers, and they do a pretty nice job. Couple them with=20 > binary-to-binary profiling compilers (these are something=20 > really cool!),=20 > and you will obtain something impossible to do by hand I agree. =20 > For example: the part I hated most of the Delphi runtime (not=20 > the VCL,=20 > however. That's pure Object Pascal) was that it's about 50%=20 > ASM, not even=20 > inline assembly (heck, I wouldn't understand it, but at least I could=20 > *compile* it), I'm talking about macro-ASM files that need=20 > their commercial=20 > (100$ and being sold only in the US) assembler, Tasm32, to be built Yes. Also i hate pascal. :) Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys =20 |
|
From: Jason H. <jas...@bt...> - 2001-10-24 21:59:08
|
While I don't want to kick up a fuss in this discussion I would like to
point out firstly that search techniques in general rely on the structure to
be searched being sorted into some specific order. It would be unreasonable
to sort a string just so you can find the instance of a null, and it would
invalidate the result anyway. ;) There isn't much more you can do in
searching a string except by going in sequence through it. I know it has
been mentioned that maybe a compiler has optimisations to work around
searching the entire length of a string to find it's end, but it's not
something you can rely on. Adding these features would introduce a great
deal of complexity into the compiler, but that is up to whoever writes it. I
think you will find that the majority of compilers will actualy deal with
string operations in the way you would expect from an external viewpoint.
You will note that that standard C/C++ does not rely on knowing the lengths
of arrays and will overrun their ends if you are not careful. I would think
that if the compiler had extra info about a string like it's length then it
would use it in cases like this. In the end it's not something I have to
worry about.
Secondly, the use of the '\0' character is fairly limited, but there are
some cases where it may be used. I agree that using it to manualy null
terminate a string literal is bad practice and should be avoided.
Possibilities for use of '\0' are:
Manualy null terminating a string, i.e.
char str[27];
for(char i = 0; i < 26; ++i) str[i] = 'A' + i;
str[26] = '\0';
cout << str;
Of course you could just as easily use a zero, but '\0' is in context to the
operation this way.
or
unsigned char str[] = {'\200', '\250', '\210', '\300', '\0'};
I've not looked up what those numbers do, but generally there are additional
characters after 127 decimal (177 octal) that are special, i.e. graphics
characters. I remind you that a backslash followed by a number is an octal
number and not a decimal.
Also I could envisage using it within a string literal as a way of breaking
it up i.e. "Hello.\0This is a test.\0Break!", of course I wouldn't recomend
using a structure like this generally, but it's not impossible to envision a
need for it. You would have to parse it manualy to obtain the strings or
other data from it.
Just some thoughts, Jason.
----- Original Message -----
From: "Ioannis Vranos" <no...@ya...>
To: "Dev-C++" <dev...@li...>
Sent: Wednesday, October 24, 2001 10:48 PM
Subject: RE: [Dev-C++] Errorhandling
> -----Original Message-----
> From: Juliet [mailto:no...@li...]
> Sent: Wednesday, October 24, 2001 9:15 PM
> To: Ioannis Vranos
> Subject: RE: [Dev-C++] Errorhandling
>
>
> At 11.47 23/10/2001 +0200, you wrote:
> >Uf. I do not want to open issues here, but there are many searching
> >algorithms (which i do not know). One efficient the C
> library provides is
> >bsearch().
>
> That would be overkill in this case :) Think about it, what
> does strcat do?
> it finds the end of the first string, then starts copying the
> second string
> into it, until that string ends too. You'd be right if the
> EOS wasn't a
> single character but rather some character sequence, hopefully the C
> designers weren't that stupid :)
I am not talking about strcat(). I am talking in general stating that
"string\0" only bad things can cause (except we need that particular
form and we know what we are doing). Because the person who writes
"string\0" doesn't seem to know that "string" has a '\0' automatically.
Anyway the implementation of strcat() would be enough stupid if it
searched character after character (even if it was written in C itself).
Many compiler operations are written in very much low level and system
dependent way so we can't know how exactly strcat() is written (with the
exception we have the source code). For example see 8.7 in K&R. Also see
header files of Dev-C++ to see Windows dependent declarations even
there. The only thing we know is that strcat() must replace the first
'\0' it finds so thinking of it looking character after character
doesn't cause any harm.
>
> >It can be written in assembly, pascal (as in C++ Builder)
> with a C type
> >interface, e.t.c..
>
> Generally a language's runtime is written in the same language, for
> essentially one reason: developers willing to learn from it
> and improve it
> won't need extra tools, compilers or knowledge of foreign
> languages. In
> particular, using ASM is the worst thing you could do
It is not necessary to have the source code of the implementation of the
library. It may come in precompiled form and only the header files with
the declarations to be supplied. It is also possible to not even have
any source files at all, and #include statements to work as switches as
i mentioned some day (but the #include mechanism *must* behave as if
there are source files and are included, the same it does with our
header files). So it is safe to always think that #include includes
header files even if this is not the case.
>
> You *need* ASM only to use features of the particular architecture
> (interrupts/traps, instructions implementing whole functions,
> native large
> integers, native floats, etc.), not covered by normal
> languages (exactly
> because of their specificity). The speed/optimization thing
> should be left
> to the compilers, and they do a pretty nice job. Couple them with
> binary-to-binary profiling compilers (these are something
> really cool!),
> and you will obtain something impossible to do by hand
I agree.
> For example: the part I hated most of the Delphi runtime (not
> the VCL,
> however. That's pure Object Pascal) was that it's about 50%
> ASM, not even
> inline assembly (heck, I wouldn't understand it, but at least I could
> *compile* it), I'm talking about macro-ASM files that need
> their commercial
> (100$ and being sold only in the US) assembler, Tasm32, to be built
Yes.
Also i hate pascal. :)
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
* Alternative URL: http://run.to/noicys
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Ioannis V. <no...@ya...> - 2001-10-25 11:07:49
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Jason Hardman
> Sent: Wednesday, October 24, 2001 11:59 PM
> To: Dev-C++
> Subject: Re: [Dev-C++] Errorhandling
>=20
>=20
> While I don't want to kick up a fuss in this discussion I=20
> would like to point out firstly that search techniques in=20
> general rely on the structure to be searched being sorted=20
> into some specific order. It would be unreasonable to sort a=20
> string just so you can find the instance of a null, and it=20
> would invalidate the result anyway. ;) There isn't much more=20
> you can do in searching a string except by going in sequence=20
> through it. I know it has been mentioned that maybe a=20
You are talking about ANSI C way. But compiler stuff can be written in a
system dependend and more close to the machine way, so it can use win32
for example. It can use assembly, and generally the compiler knows
*more* than us from outside the compiler. As a hint take for example
sizeof. sizeof even for ANSI standard knows the length of an array in
the scope it was defined. How does it know? It's compiler stuff and
compiler knows. So strcat() to search character after character would be
stupid for a nowadays compiler. But it is *safe* to assume it looks
character after character to find the '\0'. As it is safe to assume it
is written in C doing that, but of course it can be written in whatever
language the compiler author wants (assembly, C++, ...). Usually C and
C++ are the case but it could be even fortran for some special cases
(precompiled the implementation file).
> compiler has optimisations to work around searching the=20
> entire length of a string to find it's end, but it's not=20
> something you can rely on. Adding these features would=20
> introduce a great deal of complexity into the compiler, but=20
> that is up to whoever writes it. I think you will find that=20
> the majority of compilers will actualy deal with string=20
> operations in the way you would expect from an external=20
> viewpoint. You will note that that standard C/C++ does not=20
Yes that's what i said.
> rely on knowing the lengths of arrays and will overrun their=20
ANSI C/C++ know the length of the arrays in the scope they were declared
using sizeof.
> ends if you are not careful. I would think that if the
> compiler had extra info about a string like it's length then=20
> it would use it in cases like this. In the end it's not=20
Yes it probably does.
> something I have to worry about.
I agree very much. :)
> Secondly, the use of the '\0' character is fairly limited,=20
> but there are some cases where it may be used. I agree that=20
> using it to manualy null terminate a string literal is bad=20
> practice and should be avoided.
>=20
> Possibilities for use of '\0' are:
>=20
> Manualy null terminating a string, i.e.
>=20
> char str[27];
> for(char i =3D 0; i < 26; ++i) str[i] =3D 'A' + i;
> str[26] =3D '\0';
> cout << str;
>=20
> Of course you could just as easily use a zero, but '\0' is in=20
> context to the operation this way.
Yes i agree but this is another case.
> or
>=20
> unsigned char str[] =3D {'\200', '\250', '\210', '\300', '\0'};
>=20
> I've not looked up what those numbers do, but generally there=20
> are additional characters after 127 decimal (177 octal) that=20
> are special, i.e. graphics characters. I remind you that a=20
> backslash followed by a number is an octal number and not a decimal.
A number having a \ is an escape sequence, *not* an octal number. 0200
is an octal number (without ' ').
=20
> Also I could envisage using it within a string literal as a=20
> way of breaking it up i.e. "Hello.\0This is a test.\0Break!",=20
Yes, but this is another case.
> of course I wouldn't recomend using a structure like this=20
> generally, but it's not impossible to envision a need for it.=20
> You would have to parse it manualy to obtain the strings or=20
> other data from it.
>=20
> Just some thoughts, Jason.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
* Alternative URL: http://run.to/noicys
|
|
From: Jason H. <jas...@bt...> - 2001-10-25 14:13:52
|
> As a hint take for example
> sizeof. sizeof even for ANSI standard knows the length of an array in
> the scope it was defined. How does it know? It's compiler stuff and
> compiler knows. So strcat() to search character after character would =
be
> stupid for a nowadays compiler. But it is *safe* to assume it looks
> character after character to find the '\0'.
It's important to realise that sizeof is a special compile time =
operator. When the compiler finds it it determines the size of the data =
refered to and inserts it as a constant value. The sizeof operator won't =
work at runtime. For it to work at runtime the compiler would have to =
include a lot of extra code and information about a data type created to =
help detemine sizes, and that wouldn't follow the standard AFAICT. To do =
that would turn C/C++ into a higher level "safe" language that is also a =
lot slower. So what does strcat() or strlen() do when you pass it a =
dynamically allocated array that the compiler didn't know about at =
compile-time? It won't use the sizeof.
=20
> unsigned char str[] =3D {'\200', '\250', '\210', '\300', '\0'};
>=20
> I've not looked up what those numbers do, but generally there=20
> are additional characters after 127 decimal (177 octal) that=20
> are special, i.e. graphics characters. I remind you that a=20
> backslash followed by a number is an octal number and not a decimal.
> A number having a \ is an escape sequence, *not* an octal number. 0200
> is an octal number (without ' ').
I was refering to the fact that the number following the backslash is =
interpreted as an octal constant and not as a decimal; it doesn't need =
the preceding zero. Also if you write '\xff', that is a hexadecimal =
character constant.
Regards, Jason.
|
|
From: Ioannis V. <no...@ya...> - 2001-10-25 20:52:34
|
Isn't it possible for an internal "sizeof style" mechanism that
determines the size of the data and insert it as a constant value in any
function, at a specific system?
=20
=20
For the rest check the following C++ code:
=20
#include <cstdio>
=20
int main()
{
using namespace std;
=20
printf("%d %u\n\n", '\200', '\200');
printf("%d %u\n", 0200, 0200);
}
=20
=20
Btw for what about are we arguing for? (If we are arguing) :)
=20
=20
Ioannis
=20
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
<http://www.noicys.f2s.com/>=20
* Alternative URL: http://run.to/noicys
=20
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Jason
Hardman
Sent: Thursday, October 25, 2001 4:13 PM
To: Dev-C++
Subject: Re: [Dev-C++] Errorhandling
> As a hint take for example
> sizeof. sizeof even for ANSI standard knows the length of an array in
> the scope it was defined. How does it know? It's compiler stuff and
> compiler knows. So strcat() to search character after character would
be
> stupid for a nowadays compiler. But it is *safe* to assume it looks
> character after character to find the '\0'.
=20
It's important to realise that sizeof is a special compile time
operator. When the compiler finds it it determines the size of the data
refered to and inserts it as a constant value. The sizeof operator won't
work at runtime. For it to work at runtime the compiler would have to
include a lot of extra code and information about a data type created to
help detemine sizes, and that wouldn't follow the standard AFAICT. To do
that would turn C/C++ into a higher level "safe" language that is also a
lot slower. So what does strcat() or strlen() do when you pass it a
dynamically allocated array that the compiler didn't know about at
compile-time? It won't use the sizeof. =20
=20
> unsigned char str[] =3D {'\200', '\250', '\210', '\300', '\0'};
>=20
> I've not looked up what those numbers do, but generally there=20
> are additional characters after 127 decimal (177 octal) that=20
> are special, i.e. graphics characters. I remind you that a=20
> backslash followed by a number is an octal number and not a decimal.
> A number having a \ is an escape sequence, *not* an octal number. 0200
> is an octal number (without ' ').
=20
I was refering to the fact that the number following the backslash is
interpreted as an octal constant and not as a decimal; it doesn't need
the preceding zero. Also if you write '\xff', that is a hexadecimal
character constant.
=20
Regards, Jason.
|
|
From: Jason H. <jas...@bt...> - 2001-10-25 22:05:40
|
MessageYou cannot always know the length of an array or string at = compile time. It is possible for things like array size and such to be = determined at compile-time and at run-time (depending), but by doing it = at run-time you are incurring an overhead in your code, which isn't part = of the C style of programming. Adding these mechanisms to C code with = hidden compiler features would be breaking the general C/C++ ethic, at = least in my view. The only reason I'm 'discussing' this is because the more I think about = it the more I come to believe that it's more likely that standard = functions like strcat() and strlen() will determine the length of the = string by going all the way through the string until null. I know this = is an old argument, but I find it difficult to believe that it would be = done a different way. C doesn't actualy have native support for strings, = it just uses an array of chars, and allows the definition of string = literals. In Pascal, for example, it does have native support for strings and you = will find that it will store a pointer to an array and the first element = of the array will be the length of the string that follows. If you want we can end this particular argument and settle on the fact = that we are both willing to differ in opinion, and that it doesn't = matter which is true 'cos it still works no matter what. Jason. ----- Original Message -----=20 From: Ioannis Vranos=20 To: Dev-C++=20 Sent: Thursday, October 25, 2001 10:54 PM Subject: RE: [Dev-C++] Errorhandling Isn't it possible for an internal "sizeof style" mechanism that = determines the size of the data and insert it as a constant value in any = function, at a specific system? Btw for what about are we arguing for? (If we are arguing) :) Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys -----Original Message----- From: dev...@li... = [mailto:dev...@li...] On Behalf Of Jason = Hardman Sent: Thursday, October 25, 2001 4:13 PM To: Dev-C++ Subject: Re: [Dev-C++] Errorhandling > As a hint take for example > sizeof. sizeof even for ANSI standard knows the length of an array = in > the scope it was defined. How does it know? It's compiler stuff = and > compiler knows. So strcat() to search character after character = would be > stupid for a nowadays compiler. But it is *safe* to assume it = looks > character after character to find the '\0'. It's important to realise that sizeof is a special compile time = operator. When the compiler finds it it determines the size of the data = refered to and inserts it as a constant value. The sizeof operator won't = work at runtime. For it to work at runtime the compiler would have to = include a lot of extra code and information about a data type created to = help detemine sizes, and that wouldn't follow the standard AFAICT. To do = that would turn C/C++ into a higher level "safe" language that is also a = lot slower. So what does strcat() or strlen() do when you pass it a = dynamically allocated array that the compiler didn't know about at = compile-time? It won't use the sizeof. =20 > unsigned char str[] =3D {'\200', '\250', '\210', '\300', '\0'}; >=20 > I've not looked up what those numbers do, but generally there=20 > are additional characters after 127 decimal (177 octal) that=20 > are special, i.e. graphics characters. I remind you that a=20 > backslash followed by a number is an octal number and not a = decimal. > A number having a \ is an escape sequence, *not* an octal number. = 0200 > is an octal number (without ' '). I was refering to the fact that the number following the backslash = is interpreted as an octal constant and not as a decimal; it doesn't = need the preceding zero. Also if you write '\xff', that is a hexadecimal = character constant. Regards, Jason. |
|
From: Ioannis V. <no...@ya...> - 2001-10-25 21:03:11
|
About '\some_number' and octal, you are right i checked so i recall the last C style code. :) =20 About the rest concerning compiler implementation and system dependend (and some times in another language) code i insist. :) =20 =20 Ioannis =20 * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com <http://www.noicys.f2s.com/>=20 * Alternative URL: http://run.to/noicys =20 -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Jason Hardman Sent: Thursday, October 25, 2001 4:13 PM To: Dev-C++ Subject: Re: [Dev-C++] Errorhandling > As a hint take for example > sizeof. sizeof even for ANSI standard knows the length of an array in > the scope it was defined. How does it know? It's compiler stuff and > compiler knows. So strcat() to search character after character would be > stupid for a nowadays compiler. But it is *safe* to assume it looks > character after character to find the '\0'. =20 It's important to realise that sizeof is a special compile time operator. When the compiler finds it it determines the size of the data refered to and inserts it as a constant value. The sizeof operator won't work at runtime. For it to work at runtime the compiler would have to include a lot of extra code and information about a data type created to help detemine sizes, and that wouldn't follow the standard AFAICT. To do that would turn C/C++ into a higher level "safe" language that is also a lot slower. So what does strcat() or strlen() do when you pass it a dynamically allocated array that the compiler didn't know about at compile-time? It won't use the sizeof. =20 =20 > unsigned char str[] =3D {'\200', '\250', '\210', '\300', '\0'}; >=20 > I've not looked up what those numbers do, but generally there=20 > are additional characters after 127 decimal (177 octal) that=20 > are special, i.e. graphics characters. I remind you that a=20 > backslash followed by a number is an octal number and not a decimal. > A number having a \ is an escape sequence, *not* an octal number. 0200 > is an octal number (without ' '). =20 I was refering to the fact that the number following the backslash is interpreted as an octal constant and not as a decimal; it doesn't need the preceding zero. Also if you write '\xff', that is a hexadecimal character constant. =20 Regards, Jason. |
|
From: Marton R. <mar...@ho...> - 2001-10-26 02:37:43
|
Hello all,
I'm a programming student currently in my C++ part 2 class.
Please tell me why the following code gives me errors with any of the three
commented floating point formatting code un-commented? I get errors with
three different compilers.
If anyone knows how to fix this please help. Or, if anyone knows another way
to format floating point data please help.
Thanks,
Marton D. Rusk
#include <iostream>
#include <iomanip>
using namespace std;
//cout << fixed << showpoint; //don't work
//cout.setf(ios::fixed, ios::floatfield); //don't work
//cout.setf(ios::showpoint);
//cout.setf(ios_base::fixed, ios_base::floatfield); //don't work
//cout.setf(ios_base::showpoint);
int main(){
float number = 3.57890;
cout << number;
return 0;
}
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
|