dev-cpp-users Mailing List for Dev-C++ (Page 573)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
| 2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
| 2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
| 2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
| 2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
| 2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
| 2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
| 2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
| 2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
| 2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
| 2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
| 2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
| 2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Jason H. <jas...@nt...> - 2002-06-11 22:46:45
|
CVS stands for Concurrent Versions System, and is a tool to enable a group of people to work with the source of a program. Significantly CVS is available for use on sourceforge, and allows a developer to "checkout" a particular source file work on it and store the changes/fixes back with the original. With a CVS archive you can regress your sourcecode to an earlier state, or branch off and perform two concurrent developments. It's something I'm still trying to learn so I probably am not explaining it very well, but you can find more info in the sourceforge docs or here at: http://www.cvshome.org/ Jason. ----- Original Message ----- From: "Ioannis Vranos" <no...@ho...> To: "Dev-C++ Mailing List" <dev...@li...> Sent: Tuesday, June 11, 2002 11:34 PM Subject: RE: [Dev-C++] MINGW GCC 3.x II > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Colin Laplace > Sent: Wednesday, June 12, 2002 1:25 AM > To: dev...@li... > Subject: Re: [Dev-C++] MINGW GCC 3.x II > > > Hello, > > I will do tests on gcc 3.1 to see if it's stable enough for > inclusion in main > Dev-C++ distribution. Everybody feel free to email me the > problems you may be > having with it, comparing to the good old gcc 2.95.3. > > Greetings, > Colin Ok but use the CVS distribution (what exactly is CVS?). I reported a very minor bug in 3.1's stdio.h and they told me it was already fixed in the CVS distribution, and "the sourceforge binaries will be updated sometime soon". Except of this, GCC 3.1 is *excellent*, it provides useful warnings and stuff (and is probably 100% standard C++ compliant or at least very close to it, since i have not found any C++ construct so far that it doesn't support, (in contrast to the classic 2.95.x distributions, 2.95.x were made in the 1997 era, and only bug fixes were provided since the original version). Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys _______________________________________________________________ Multimillion Dollar Computer Inventory Live Webcast Auctions Thru Aug. 2002 - http://www.cowanalexander.com/calendar _______________________________________________ Dev-cpp-users mailing list Dev...@li... https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: Ioannis V. <no...@ho...> - 2002-06-11 22:34:35
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Colin Laplace > Sent: Wednesday, June 12, 2002 1:25 AM > To: dev...@li... > Subject: Re: [Dev-C++] MINGW GCC 3.x II > > > Hello, > > I will do tests on gcc 3.1 to see if it's stable enough for > inclusion in main > Dev-C++ distribution. Everybody feel free to email me the > problems you may be > having with it, comparing to the good old gcc 2.95.3. > > Greetings, > Colin Ok but use the CVS distribution (what exactly is CVS?). I reported a very minor bug in 3.1's stdio.h and they told me it was already fixed in the CVS distribution, and "the sourceforge binaries will be updated sometime soon". Except of this, GCC 3.1 is *excellent*, it provides useful warnings and stuff (and is probably 100% standard C++ compliant or at least very close to it, since i have not found any C++ construct so far that it doesn't support, (in contrast to the classic 2.95.x distributions, 2.95.x were made in the 1997 era, and only bug fixes were provided since the original version). Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: Colin L. <col...@wa...> - 2002-06-11 22:24:13
|
Hello, I will do tests on gcc 3.1 to see if it's stable enough for inclusion in main Dev-C++ distribution. Everybody feel free to email me the problems you may be having with it, comparing to the good old gcc 2.95.3. Greetings, Colin On Saturday 08 June 2002 00:30, you wrote: > And the release notes for the MINGW GCC 3.1: > http://sourceforge.net/project/shownotes.php?release_id=90000 > > > > Ioannis > > * Ioannis Vranos > * Programming pages: http://www.noicys.cjb.net > <http://www.noicys.cjb.net/> > * Alternative URL: http://run.to/noicys ---------------------------------------- Content-Type: text/html; charset="us-ascii"; name="Attachment: 1" Content-Transfer-Encoding: quoted-printable Content-Description: ---------------------------------------- |
|
From: Colin L. <col...@wa...> - 2002-06-11 22:24:00
|
Hello, > Two links provided on the page www.bloodshed.net/dev/doc/index.html are not > working. They are Paul Gerfen,s C/C++ tutorial for Dev C++. > Please check the same and correct. > Hope this will be available soon. Dev C++ is having no > satisfactory help files or tutorials which is a defect. > Hope you will do the needful for this ( if Paul Gerfens tutorial has not > filled the gap.) It seems that Paul Gerfen is stopping his website and his removing the contents out of it. You can look at his message at http://www.peadar.ic24.net/home.html > Also please let me know is there any considerable difference between DEv > C++ 4.01 and dev C++ 5 beta. Down loading 10 MB is difficult for me with > the slow download speed. If it is worth downloading please advise me I > shall do it. There is a considerable difference, but it isn't ready yet for everyday use, unless you tweak it with latest devcpp.exe from the cvs. I would recommend to wait until version 4.9.4.0 goes out, if you have a slow and expensive connection Greetings, Colin > Thanking you, > Yours faithfully > > Ameer khan > sm...@vs... ---------------------------------------- Content-Type: text/html; charset="iso-8859-1"; name="Attachment: 1" Content-Transfer-Encoding: quoted-printable Content-Description: ---------------------------------------- |
|
From: Ioannis V. <no...@ho...> - 2002-06-11 21:05:07
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of S=F6r=F6s J=F3zsef > Sent: Tuesday, June 11, 2002 11:27 PM > To: dev...@li... > Subject: [Dev-C++] unsubscribe http://www.noicys.cjb.net/devcpp/ub.htm Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: <sor...@mu...> - 2002-06-11 20:27:45
|
-----Original Message----- From: dev...@li... [mailto:dev...@li...]On Behalf Of dev...@li... Sent: 2002. június 11. 21:03 To: dev...@li... Subject: Dev-cpp-users digest, Vol 1 #815 - 6 msgs Send Dev-cpp-users mailing list submissions to dev...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/dev-cpp-users or, via email, send a message with subject or body 'help' to dev...@li... You can reach the person managing the list at dev...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of Dev-cpp-users digest..." Today's Topics: 1. Re: unsubscribe unsuscribe (Hongli Lai) 2. (no subject) (balamurali muraleedharan) 3. doubt (balamurali muraleedharan) 4. double no double query (Daniel Glenfield) 5. Re: doubt (Abhijit Shylanath) 6. Re: doubt (Mac Reiter) --__--__-- Message: 1 Subject: Re: [Dev-C++] unsubscribe unsuscribe From: Hongli Lai <h....@ch...> To: "Garcia Sanchez, Jesus "Angel <jag...@in...> Cc: Dev...@li... Date: 11 Jun 2002 14:47:18 +0200 On Tue, 2002-06-11 at 13:32, Garcia Sanchez, Jesus Angel wrote: > > unsubscribe > unsuscribe > Have you ever read the *unsubscribe instructions* on the website....? Here's a hint: http://devcpp.everfloyd.com/help.html Perhaps I should make the sentence "If you want to know how to unsubscribe from this list, go to this page!" blinking and 1000 pixels big. --__--__-- Message: 2 Date: 11 Jun 2002 13:54:01 -0000 From: "balamurali muraleedharan" <bal...@re...> Reply-To: "balamurali muraleedharan" <bal...@re...> To: dev...@li... Subject: [Dev-C++] (no subject) confirm 399103 _________________________________________________________ Click below to visit monsterindia.com and review jobs in India or Abroad http://monsterindia.rediff.com/jobs --__--__-- Message: 3 Date: 11 Jun 2002 13:55:43 -0000 From: "balamurali muraleedharan" <bal...@re...> Reply-To: "balamurali muraleedharan" <bal...@re...> To: dev...@li... Subject: [Dev-C++] doubt Sir, I know that when u open an image file in the text mode we cant see the image but when we open it in binary mode we should be able to read the data from it and store it in any structure.Since this is what my doubt is all about I present it here. struct bitmapfileheader { short int signature;/*2bytes*/ int filesize;/*4bytes*/ int reserved;/*4bytes*/ int dataoffset;/*4bytes*/ }; int main() { bitmapfileheader bmpf; cout<<sizeof(bmpf); } here the result shows the size as 16bytes instead of 14bytes also while reading into this structure using file.open and file.read statement always wrong data is contained in the structure where the read data is stored.Why is this so? There is error only while reading into the structure as a whole as in the case file.open("file.bmp",ios::binary|ios::in); file.read((char*)&bmpf,sizeof(bmpf)); This always reads erroneous values into the corresponding elements in the structure.But file.open("file.bmp",ios::binary|ios::in); file.read((char*)&bmpf.signature,sizeof(bmpf.signature)); file.read((char*)&bmpf.filesize,sizeof(bmpf.filesize)); file.read((char*)&bmpf.reserved,sizeof(bmpf.reserved)); file.read((char*)&bmpf.dataoffset,sizeof(bmpf.dataoffset); this reads the correct values into the respective elements of the structure. why is this so? why cant we simply read the contents of the file into the structure using the first statement?what really happens during this process? I am using G++ in Linux environment. Please help me. _________________________________________________________ Click below to visit monsterindia.com and review jobs in India or Abroad http://monsterindia.rediff.com/jobs --__--__-- Message: 4 From: "Daniel Glenfield" <sp...@ho...> To: dev...@li... Date: Tue, 11 Jun 2002 15:27:33 +0100 Subject: [Dev-C++] double no double query if you are using the same object to write multiple variables into the text document try destroying the object then re-creating it before you do the next one. It's a bit like the following. e.g. [code] /** Object with local scope Notice how the strstream object is created with local scope. Local scope ensures the object is destroyed, then created the next time it is needed. This has the effect of making sure that no previous values will be carried forward to the next usage of the object. */ { // Display X Resolution strstream StrstreamObject; StrstreamObject << "XResolution: " << m_nXResolution << '\0'; pListbox->AddString(StrstreamObject.str()); StrstreamObject.rdbuf()->freeze(0); } { // Now for the Y resolution strstream StrstreamObject; StrstreamObject << "YResolution: " << m_nYResolution << '\0'; pListbox->AddString(StrstreamObject.str()); StrstreamObject.rdbuf()->freeze(0); } [/code] _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com --__--__-- Message: 5 From: "Abhijit Shylanath" <mu...@gm...> To: <dev...@li...> Subject: Re: [Dev-C++] doubt Date: Tue, 11 Jun 2002 21:05:47 +0530 Organization: Retrogression AFAIK, GCC (and derivatives) don't store structures linearly, they pad the elements for optimization reasons. So if you want to read in stuff, you'll have to read them in separately. I think there's a command-line option somewhere to disable this behaviour... Over to you, <put_your_name_here>. -------------------------- http://mudeth.tripod.com ----- Original Message ----- From: "balamurali muraleedharan" <bal...@re...> To: <dev...@li...> Sent: Tuesday, June 11, 2002 7:25 PM Subject: [Dev-C++] doubt > int main() > { > bitmapfileheader bmpf; > cout<<sizeof(bmpf); > } > here the result shows the size as 16bytes instead of 14bytes > also while reading into this structure using file.open and > file.read statement always wrong data is contained in the > structure where the read data is stored.Why is this so? > There is error only while reading into the structure as a whole as > in the case > file.open("file.bmp",ios::binary|ios::in); > file.read((char*)&bmpf,sizeof(bmpf)); > This always reads erroneous values into the corresponding elements > in the structure.But > file.open("file.bmp",ios::binary|ios::in); > file.read((char*)&bmpf.signature,sizeof(bmpf.signature)); > file.read((char*)&bmpf.filesize,sizeof(bmpf.filesize)); > file.read((char*)&bmpf.reserved,sizeof(bmpf.reserved)); > file.read((char*)&bmpf.dataoffset,sizeof(bmpf.dataoffset); > this reads the correct values into the respective elements of the > structure. > why is this so? > why cant we simply read the contents of the file into the > structure using the first statement?what really happens during > this process? > I am using G++ in Linux environment. > Please help me. --__--__-- Message: 6 Date: Tue, 11 Jun 2002 10:53:54 -0500 To: dev...@li... From: "Mac Reiter" <re...@no...> Subject: Re: [Dev-C++] doubt Compilers are allowed to pack structures in memory any way they want. The only requirements on the compiler are that: 1. sizeof() will report the actual size 2. field access will work x86 CPUs (386/486/Pentium/II/III/IV/etc and so on) are much more efficient working with longs than with shorts. More importantly, these processors (and most others) are *MUCH* more efficient working with longs that are 4 byte aligned in memory (4 byte aligned means the memory address is evenly divisible by 4 -- or that the bottom two bits of the address are 0, if you prefer to think that way). If the compiler packed your structure tightly, the three longs would all end up 2 byte aligned, but not 4 byte aligned, and accessing them would take over twice as long. Since the compiler does not know how you intend to use this structure, it adds some padding so that the long fields will be properly aligned. The effective struct you end up using actually looks like this (probably): struct bitmapfileheader { short int signature;/*2bytes*/ short int PADDING1;/*2bytes*/ int filesize;/*4bytes*/ int reserved;/*4bytes*/ int dataoffset;/*4bytes*/ }; That explains why you can't just read the structure directly. Using the stream operators to push structures/classes into streams and pull them back out is fine, but it requires that the stream operators be used for both operations. In your case (reading bitmap files), the header was not written by a stream operator, so you can't read it back out that way. ************* It is also unwise to attempt raw structure dumping like this because the structure layout in memory will change between compilers, and can change even between versions of the same compiler (GCC 2.95 and GCC 3.1 have some memory layout differences). ************* The most "object oriented" way of handling this (which is also the idealogically correct approach when working with stream insertion/extraction operators), is to write operator<<() and operator>>() member functions for your structures. Inside those functions, you use the code you showed below: >file.read((char*)&bmpf.signature,sizeof(bmpf.signature)); >file.read((char*)&bmpf.filesize,sizeof(bmpf.filesize)); >file.read((char*)&bmpf.reserved,sizeof(bmpf.reserved)); >file.read((char*)&bmpf.dataoffset,sizeof(bmpf.dataoffset); but modified to make sense inside that member function. Actually, what would be _even_better_ is the following: file >> signature; file >> filesize; file >> reserved; file >> dataoffset; or possibly even (forgive me if this is in error -- I'm not a big stream user myself...) file >> signature >> filesize >> reserved >> dataoffset; Since you are working with built in data types at this level, the stream extraction operator know how to read them from the stream directly. Once you have written those member functions, you can then insert or extract your structure directly into or out of streams. Any decent book on C++ programming *SHOULD* have samples of operator<<() and operator>>(), since it is a relatively important functionality, and one of the primary benefits of the stream system. If you insist on raw memory dumping, most compilers have a method of telling the compiler to pack tightly in memory. This is frequently done with one of the many "#pragma" directives. Someone with more GCC background will have to supply the actual command, or you can get it from the man pages. Using these directives is inherently unportable and will limit your code to only functioning on GCC on the particular CPU architecture you are using, so I would recommend using the more object oriented approach from above. Good luck, Mac At 01:55 PM 6/11/02 -0000, balamurali muraleedharan wrote: >Sir, >I know that when u open an image file in the text mode we cant see >the image but when we open it in binary mode we should be able to >read the data from it and store it in any structure.Since this is >what my doubt is all about I present it here. > >struct bitmapfileheader >{ >short int signature;/*2bytes*/ >int filesize;/*4bytes*/ >int reserved;/*4bytes*/ >int dataoffset;/*4bytes*/ >}; > >int main() >{ >bitmapfileheader bmpf; >cout<<sizeof(bmpf); >} >here the result shows the size as 16bytes instead of 14bytes >also while reading into this structure using file.open and >file.read statement always wrong data is contained in the >structure where the read data is stored.Why is this so? >There is error only while reading into the structure as a whole as >in the case >file.open("file.bmp",ios::binary|ios::in); >file.read((char*)&bmpf,sizeof(bmpf)); >This always reads erroneous values into the corresponding elements >in the structure.But >file.open("file.bmp",ios::binary|ios::in); >file.read((char*)&bmpf.signature,sizeof(bmpf.signature)); >file.read((char*)&bmpf.filesize,sizeof(bmpf.filesize)); >file.read((char*)&bmpf.reserved,sizeof(bmpf.reserved)); >file.read((char*)&bmpf.dataoffset,sizeof(bmpf.dataoffset); >this reads the correct values into the respective elements of the >structure. >why is this so? >why cant we simply read the contents of the file into the >structure using the first statement?what really happens during >this process? >I am using G++ in Linux environment. >Please help me. >_________________________________________________________ >Click below to visit monsterindia.com and review jobs in India or >Abroad >http://monsterindia.rediff.com/jobs > > >_______________________________________________________________ > >Don't miss the 2002 Sprint PCS Application Developer's Conference >August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink > >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > - _____________________________ /"\ Mac Reiter \ / ASCII Ribbon Campaign Nomadics, Inc. X Against HTML Mail re...@no... / \ (To join the campaign, simply use this in your signature.) --__--__-- _______________________________________________ Dev-cpp-users mailing list Dev...@li... https://lists.sourceforge.net/lists/listinfo/dev-cpp-users End of Dev-cpp-users Digest |
|
From: Carlos d. M. <cg...@wo...> - 2002-06-11 19:10:52
|
I upgraded the mingw to the 1.1 version, and it works fine, but I want advice you that if you usually use conio.c, you can, before extracting it to the Dev-C++ directory, copy your current conio.h and conio.c to another dir and use it from other dir or with another name, because the conio which is in mingw1.1 is not the same, and some of the capabilities of the previous are lost. I don't use it from some time ago, and I don't remember it perfectly right now, but I think that with the current I could not set the colors of text and background or if it was another functions which made errors in compiling, the same source that I compiled ok with the previous one.. |
|
From: Carlos d. M. <cg...@wo...> - 2002-06-11 19:10:51
|
No, the code posted is all the source code between #defines, main() varia=
ble declaration and
return. I compiled it just for confirm if there could be something about =
what you say.
If I could get the iostream files from someone for which it works fine, p=
erhaps I could
compare them, (I read that a header in some compiler (mingw or borland5.5=
free) has an errata,
it can be the problem, but I don't understand, it seems nobody else has i=
t).
It happens either with #include<header.h> and with #include<header>;using=
namespace std;.
With iostream from mingw1.1 and the previous.(I have both: include/g++-3 =
=66rom one and /G++
=66rom the other)
With values of different size, small and great.
This is the whole code:
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
double tal =3D 575756.76884;
fstream fileA, fileB;
FILE *outFile, *inFile;
char intoFile[255], outtoFile[255];
double test, recep;
char recipe, *mediate;
int size;
fileA.open("marar.txt", ios::out);
fileA << tal;
fileA.close();
fileB.open("marar.txt", ios::in);
fileB >> tal;
cout << tal;
fileB.close();
system("PAUSE");
return 0;
}
Daniel Glenfield escribi=F3:
> if you are using the same object to write multiple variables into the t=
ext
> document try destroying the object then re-creating it before you do th=
e
> next one.
>
> It's a bit like the following.
>
> e.g.
> [code]
> /**
> Object with local scope
> Notice how the strstream object is created with local scope=
. Local
> scope
> ensures the object is destroyed, then created the next time=
it
> is needed. This has the effect of making sure that no previ=
ous
> values will be carried forward to the next usage of the obj=
ect.
> */
> { // Display X Resolution
> strstream StrstreamObject;
> StrstreamObject << "XResolution: " << m_nXResolution << =
'\0';
> pListbox->AddString(StrstreamObject.str());
> StrstreamObject.rdbuf()->freeze(0);
> }
>
> { // Now for the Y resolution
> strstream StrstreamObject;
> StrstreamObject << "YResolution: " << m_nYResolution << =
'\0';
> pListbox->AddString(StrstreamObject.str());
> StrstreamObject.rdbuf()->freeze(0);
> }
>
> [/code]
>
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
>
> _______________________________________________________________
>
> Don't miss the 2002 Sprint PCS Application Developer's Conference
> August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?s=
ource=3Dosdntextlink
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: Mac R. <re...@no...> - 2002-06-11 15:57:14
|
Compilers are allowed to pack structures in memory any way they want. The
only requirements on the compiler are that:
1. sizeof() will report the actual size
2. field access will work
x86 CPUs (386/486/Pentium/II/III/IV/etc and so on) are much more efficient
working with longs than with shorts. More importantly, these processors
(and most others) are *MUCH* more efficient working with longs that are 4
byte aligned in memory (4 byte aligned means the memory address is evenly
divisible by 4 -- or that the bottom two bits of the address are 0, if you
prefer to think that way). If the compiler packed your structure tightly,
the three longs would all end up 2 byte aligned, but not 4 byte aligned,
and accessing them would take over twice as long. Since the compiler does
not know how you intend to use this structure, it adds some padding so that
the long fields will be properly aligned.
The effective struct you end up using actually looks like this (probably):
struct bitmapfileheader
{
short int signature;/*2bytes*/
short int PADDING1;/*2bytes*/
int filesize;/*4bytes*/
int reserved;/*4bytes*/
int dataoffset;/*4bytes*/
};
That explains why you can't just read the structure directly. Using the
stream operators to push structures/classes into streams and pull them back
out is fine, but it requires that the stream operators be used for both
operations. In your case (reading bitmap files), the header was not
written by a stream operator, so you can't read it back out that way.
*************
It is also unwise to attempt raw structure dumping like this because the
structure layout in memory will change between compilers, and can change
even between versions of the same compiler (GCC 2.95 and GCC 3.1 have some
memory layout differences).
*************
The most "object oriented" way of handling this (which is also the
idealogically correct approach when working with stream
insertion/extraction operators), is to write operator<<() and operator>>()
member functions for your structures. Inside those functions, you use the
code you showed below:
>file.read((char*)&bmpf.signature,sizeof(bmpf.signature));
>file.read((char*)&bmpf.filesize,sizeof(bmpf.filesize));
>file.read((char*)&bmpf.reserved,sizeof(bmpf.reserved));
>file.read((char*)&bmpf.dataoffset,sizeof(bmpf.dataoffset);
but modified to make sense inside that member function. Actually, what
would be _even_better_ is the following:
file >> signature;
file >> filesize;
file >> reserved;
file >> dataoffset;
or possibly even (forgive me if this is in error -- I'm not a big stream
user myself...)
file >> signature >> filesize >> reserved >> dataoffset;
Since you are working with built in data types at this level, the stream
extraction operator know how to read them from the stream directly.
Once you have written those member functions, you can then insert or
extract your structure directly into or out of streams. Any decent book on
C++ programming *SHOULD* have samples of operator<<() and operator>>(),
since it is a relatively important functionality, and one of the primary
benefits of the stream system.
If you insist on raw memory dumping, most compilers have a method of
telling the compiler to pack tightly in memory. This is frequently done
with one of the many "#pragma" directives. Someone with more GCC
background will have to supply the actual command, or you can get it from
the man pages. Using these directives is inherently unportable and will
limit your code to only functioning on GCC on the particular CPU
architecture you are using, so I would recommend using the more object
oriented approach from above.
Good luck,
Mac
At 01:55 PM 6/11/02 -0000, balamurali muraleedharan wrote:
>Sir,
>I know that when u open an image file in the text mode we cant see
>the image but when we open it in binary mode we should be able to
>read the data from it and store it in any structure.Since this is
>what my doubt is all about I present it here.
>
>struct bitmapfileheader
>{
>short int signature;/*2bytes*/
>int filesize;/*4bytes*/
>int reserved;/*4bytes*/
>int dataoffset;/*4bytes*/
>};
>
>int main()
>{
>bitmapfileheader bmpf;
>cout<<sizeof(bmpf);
>}
>here the result shows the size as 16bytes instead of 14bytes
>also while reading into this structure using file.open and
>file.read statement always wrong data is contained in the
>structure where the read data is stored.Why is this so?
>There is error only while reading into the structure as a whole as
>in the case
>file.open("file.bmp",ios::binary|ios::in);
>file.read((char*)&bmpf,sizeof(bmpf));
>This always reads erroneous values into the corresponding elements
>in the structure.But
>file.open("file.bmp",ios::binary|ios::in);
>file.read((char*)&bmpf.signature,sizeof(bmpf.signature));
>file.read((char*)&bmpf.filesize,sizeof(bmpf.filesize));
>file.read((char*)&bmpf.reserved,sizeof(bmpf.reserved));
>file.read((char*)&bmpf.dataoffset,sizeof(bmpf.dataoffset);
>this reads the correct values into the respective elements of the
>structure.
>why is this so?
>why cant we simply read the contents of the file into the
>structure using the first statement?what really happens during
>this process?
>I am using G++ in Linux environment.
>Please help me.
>_________________________________________________________
>Click below to visit monsterindia.com and review jobs in India or
>Abroad
>http://monsterindia.rediff.com/jobs
>
>
>_______________________________________________________________
>
>Don't miss the 2002 Sprint PCS Application Developer's Conference
>August 25-28 in Las Vegas -
http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
>
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
-
_____________________________ /"\
Mac Reiter \ / ASCII Ribbon Campaign
Nomadics, Inc. X Against HTML Mail
re...@no... / \ (To join the campaign, simply use
this in your signature.)
|
|
From: Abhijit S. <mu...@gm...> - 2002-06-11 15:37:00
|
AFAIK, GCC (and derivatives) don't store structures linearly, they pad the elements for optimization reasons. So if you want to read in stuff, you'll have to read them in separately. I think there's a command-line option somewhere to disable this behaviour... Over to you, <put_your_name_here>. -------------------------- http://mudeth.tripod.com ----- Original Message ----- From: "balamurali muraleedharan" <bal...@re...> To: <dev...@li...> Sent: Tuesday, June 11, 2002 7:25 PM Subject: [Dev-C++] doubt > int main() > { > bitmapfileheader bmpf; > cout<<sizeof(bmpf); > } > here the result shows the size as 16bytes instead of 14bytes > also while reading into this structure using file.open and > file.read statement always wrong data is contained in the > structure where the read data is stored.Why is this so? > There is error only while reading into the structure as a whole as > in the case > file.open("file.bmp",ios::binary|ios::in); > file.read((char*)&bmpf,sizeof(bmpf)); > This always reads erroneous values into the corresponding elements > in the structure.But > file.open("file.bmp",ios::binary|ios::in); > file.read((char*)&bmpf.signature,sizeof(bmpf.signature)); > file.read((char*)&bmpf.filesize,sizeof(bmpf.filesize)); > file.read((char*)&bmpf.reserved,sizeof(bmpf.reserved)); > file.read((char*)&bmpf.dataoffset,sizeof(bmpf.dataoffset); > this reads the correct values into the respective elements of the > structure. > why is this so? > why cant we simply read the contents of the file into the > structure using the first statement?what really happens during > this process? > I am using G++ in Linux environment. > Please help me. |
|
From: Daniel G. <sp...@ho...> - 2002-06-11 14:27:44
|
if you are using the same object to write multiple variables into the text
document try destroying the object then re-creating it before you do the
next one.
It's a bit like the following.
e.g.
[code]
/**
Object with local scope
Notice how the strstream object is created with local scope. Local
scope
ensures the object is destroyed, then created the next time it
is needed. This has the effect of making sure that no previous
values will be carried forward to the next usage of the object.
*/
{ // Display X Resolution
strstream StrstreamObject;
StrstreamObject << "XResolution: " << m_nXResolution << '\0';
pListbox->AddString(StrstreamObject.str());
StrstreamObject.rdbuf()->freeze(0);
}
{ // Now for the Y resolution
strstream StrstreamObject;
StrstreamObject << "YResolution: " << m_nYResolution << '\0';
pListbox->AddString(StrstreamObject.str());
StrstreamObject.rdbuf()->freeze(0);
}
[/code]
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
|
|
From: balamurali m. <bal...@re...> - 2002-06-11 13:56:39
|
Sir,
I know that when u open an image file in the text mode we cant see
the image but when we open it in binary mode we should be able to
read the data from it and store it in any structure.Since this is
what my doubt is all about I present it here.
struct bitmapfileheader
{
short int signature;/*2bytes*/
int filesize;/*4bytes*/
int reserved;/*4bytes*/
int dataoffset;/*4bytes*/
};
int main()
{
bitmapfileheader bmpf;
cout<<sizeof(bmpf);
}
here the result shows the size as 16bytes instead of 14bytes
also while reading into this structure using file.open and
file.read statement always wrong data is contained in the
structure where the read data is stored.Why is this so?
There is error only while reading into the structure as a whole as
in the case
file.open("file.bmp",ios::binary|ios::in);
file.read((char*)&bmpf,sizeof(bmpf));
This always reads erroneous values into the corresponding elements
in the structure.But
file.open("file.bmp",ios::binary|ios::in);
file.read((char*)&bmpf.signature,sizeof(bmpf.signature));
file.read((char*)&bmpf.filesize,sizeof(bmpf.filesize));
file.read((char*)&bmpf.reserved,sizeof(bmpf.reserved));
file.read((char*)&bmpf.dataoffset,sizeof(bmpf.dataoffset);
this reads the correct values into the respective elements of the
structure.
why is this so?
why cant we simply read the contents of the file into the
structure using the first statement?what really happens during
this process?
I am using G++ in Linux environment.
Please help me.
_________________________________________________________
Click below to visit monsterindia.com and review jobs in India or
Abroad
http://monsterindia.rediff.com/jobs
|
|
From: balamurali m. <bal...@re...> - 2002-06-11 13:54:59
|
confirm 399103 _________________________________________________________ Click below to visit monsterindia.com and review jobs in India or Abroad http://monsterindia.rediff.com/jobs |
|
From: Hongli L. <h....@ch...> - 2002-06-11 12:43:11
|
On Tue, 2002-06-11 at 13:32, Garcia Sanchez, Jesus Angel wrote: > > unsubscribe > unsuscribe > Have you ever read the *unsubscribe instructions* on the website....? Here's a hint: http://devcpp.everfloyd.com/help.html Perhaps I should make the sentence "If you want to know how to unsubscribe from this list, go to this page!" blinking and 1000 pixels big. |
|
From: Garcia S. J. A. <jag...@in...> - 2002-06-11 11:30:56
|
unsubscribe unsuscribe ----------------------------------------------------------------- Este correo electr=F3nico y, en su caso, cualquier fichero anexo al = mismo, contiene informaci=F3n de car=E1cter confidencial exclusivamente = dirigida a su destinatario o destinatarios. Queda prohibida su = divulgaci=F3n, copia o distribuci=F3n a terceros sin la previa = autorizaci=F3n escrita de Indra. En el caso de haber recibido este = correo electr=F3nico por error, se ruega notificar inmediatamente esta = circunstancia mediante reenv=EDo a la direcci=F3n electr=F3nica del = remitente. ----------------------------------------------------------------- The information in this e-mail and in any attachments is confidential = and solely for the attention and use of the named addressee(s). You are = hereby notified that any dissemination, distribution or copy of this = communication is prohibited without the prior written consent of Indra. = If you have received this communication in error, please, notify the = sender by reply e-mail. ----------------------------------------------------------------- |
|
From: David B. <da...@we...> - 2002-06-11 11:20:51
|
Hi, We do a lot of embedded systems development. Among other things, I use gcc for programming a 68332 microcontroller, with gdb (and sometimes gvd) for debugging. The gcc and gdb are special builds for cross-compiling - in particular, the gdb build commuicates with a hardware debugger connected to my parallel port. I would imagine that it should be reasonably straightforward to integrate the embedded compiler - after all, it is a port of gcc. The binaries have different names, however (such as "m68k-elf-gcc.exe"), the library is newlib, the linker files are heavily customised, and there are a number of command-line options that are specific to the port. The gdb port is a special build - it supports most of the standard gdb commands, but has a few additional commands (such as to configure the debugger hardware), requires customised setup scripts (to set up the target board), fails to implement certain standard commands (such as "run" - you must always use "continue"), and obviously has differences for the different processor architecture (such as completly different registers). Some users also make heavy use of the serial gdb protocol, or remote gdb systems for embedded development. Would it be possible to use dev-cpp as an IDE with these tools? Has anyone else tried using it for cross-compiling environments? At the moment, I use a general text editor, standard make, and gdb along with gvd, but it would be very interesting to be able to use an IDE. David Brown Norway |
|
From: Ioannis V. <no...@ho...> - 2002-06-11 11:03:50
|
http://www.allegro.cc I have links to other libraries at http://www.noicys.cjb.net/links.htm It is not a self-advertisement, simply i have all my favorite links there. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys > -----Original Message----- > From: prasad athreya [mailto:pra...@ho...] > Sent: Tuesday, June 11, 2002 1:55 PM > To: no...@ho... > Subject: RE: [Dev-C++] (no subject) > > > thanks a lot > btw where do u get allegro from? > > > >From: "Ioannis Vranos" <no...@ho...> > >To: "Dev-C++ Mailing List" <dev...@li...> > >Subject: RE: [Dev-C++] (no subject) > >Date: Tue, 11 Jun 2002 13:44:16 +0300 > > > > > -----Original Message----- > > > From: dev...@li... > > > [mailto:dev...@li...] On Behalf > > > Of prasad athreya > > > Sent: Tuesday, June 11, 2002 1:31 PM > > > To: dev...@li... > > > Subject: [Dev-C++] (no subject) > > > > > > > > > hello > > > im trying to improve my program by colouring the text. Im not > > > sure how > > > exactly in devcpp to do this. > > > > > >You can use some 3rd party library, like Allegro. > > > > > > > I am also trying to find out whther it is possible to > print via a USB > > > printer port > > > > > >Of course it is, you will use some system extension, e.g > some Win32 API > >call which comes with Dev-C++. I do not know the particular call > >however. > > > > > >Ioannis > > > >* Ioannis Vranos > >* Programming pages: http://www.noicys.cjb.net > >* Alternative URL: http://run.to/noicys > > > >_______________________________________________________________ > > > >Don't miss the 2002 Sprint PCS Application Developer's Conference > >August 25-28 in Las Vegas - > http://devcon.sprintpcs.com/adp/index.cfm?> source=osdntextlink > > > > > >_______________________________________________ > >Dev-cpp-users mailing list > >Dev...@li... > >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > |
|
From: Ioannis V. <no...@ho...> - 2002-06-11 10:44:30
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of prasad athreya > Sent: Tuesday, June 11, 2002 1:31 PM > To: dev...@li... > Subject: [Dev-C++] (no subject) > > > hello > im trying to improve my program by colouring the text. Im not > sure how > exactly in devcpp to do this. You can use some 3rd party library, like Allegro. > I am also trying to find out whther it is possible to print via a USB > printer port Of course it is, you will use some system extension, e.g some Win32 API call which comes with Dev-C++. I do not know the particular call however. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net * Alternative URL: http://run.to/noicys |
|
From: prasad a. <pra...@ho...> - 2002-06-11 10:31:47
|
hello im trying to improve my program by colouring the text. Im not sure how exactly in devcpp to do this. I am also trying to find out whther it is possible to print via a USB printer port Thanks _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx |
|
From: Ioannis V. <no...@ho...> - 2002-06-10 21:13:12
|
<http://run.to/noicys> -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Ameer Khan Sent: Monday, June 10, 2002 6:14 PM To: Dev...@li... Subject: [Dev-C++] Missing link from www.Bloodshed.net Dear Sir, Two links provided on the page <http://www.bloodshed.net/dev/doc/index.html> www.bloodshed.net/dev/doc/index.html are not working. They are Paul Gerfen,s C/C++ tutorial for Dev C++. Please check the same and correct. Hope this will be available soon. Dev C++ is having no satisfactory help files or tutorials which is a defect. Hope you will do the needful for this ( if Paul Gerfens tutorial has not filled the gap.) Concerning the compiler, there is always the GCC manual: <http://www.gnu.org/software/gcc/onlinedocs/> http://www.gnu.org/software/gcc/onlinedocs/ For Dev-C++ case, refer to 2.95.3 manual. Also please let me know is there any considerable difference between DEv C++ 4.01 and dev C++ 5 beta. The basic difference if i recall correctly is that 5.x uses the latest MINGW 1.1 distribution, while 4.x used an older one. Down loading 10 MB is difficult for me with the slow download speed. If it is worth downloading please advise me I shall do it. Well if i were in your case i would download the latest MINGW compiler (which is about 10 MB) and extract it above C:\ Dev-C++, since i consider the IDE of the 4.x more stable. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net <http://www.noicys.cjb.net/> * Alternative URL: http://run.to/noicys |
|
From: Ioannis V. <no...@ho...> - 2002-06-10 21:01:24
|
Yes, the new uncompressed files. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net <http://www.noicys.cjb.net/> * Alternative URL: http://run.to/noicys -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Greg Riddick Sent: Monday, June 10, 2002 5:01 PM To: Dev-C++ Mailing List Subject: [Dev-C++] Dev-C++] MINGW GCC 3.1 for Windows is out there >) I uncompressed the first on a temporary empty folder and then cut & paste above my old MINGW distribution. >Then i uncompressed the second on the temporary empty folder and then cut & paste above my old MINGW distribution. Do you mean that you pasted the new files into your MingW root directory? --Greg |
|
From: Carlos d. M. <cg...@wo...> - 2002-06-10 19:27:08
|
I have the variable double doubvar = 747675.57576;
fstream file;
file.open("archivo.txt", ios::out);
file << doubvar << endl;
file.close();
I read the file with notepad and the number lost the decimals!
And the same with cout << doubvar!
It does not happen with fprintf(file, "%lf", doubvar);
The same with long double, but with long double printf prints
-0.0000000.
????????.
_______________________________________________
|Notepad archivo.txt________________________ _ 0 X |
|747675
|
|
|
|_______________________________________________|
P.S. My Dev-C++ 4.01 (and 4.00) has the generate makefile option in the
project popup menu.
|
|
From: Carlos d. M. <cg...@wo...> - 2002-06-10 19:27:07
|
My executables write the files in its own directory.
For make a default dir you can add a variable which is the directory, for example:
default = "D:/Myapps/". [This would be inside a file you wrote in the exe's dir, see below]
used = default; The begin of the program
Then when you are asked for the file you want read/write you do:
cin >> (scanf("%s",) fileName;
Then you strcat it to the other,
strcat(used, fileName); (the used is for having default untouched)
fopen(used,
If you want to change the default:
if(youwantdoit)
cin >> default;
If you want change the current but not the default:
cin >> used.
And generate an only 1kb file with it:
file << default;
and file >> default at the begining,
so the next time it will maintain the default you set last time.
(of course this file is written in the exe's dir).
That's all.
|
|
From: Ameer K. <sm...@vs...> - 2002-06-10 17:52:27
|
Dear friends, I have recently installed Dev C++ 4.01 and like the compactness and = simplicity of it. Also i am new to Windows programming and would like to use Dev C++ as = my IDE. i have tried to create menu items for a Window created by New Projects/Window applications . After compiling and editing the resource file , I am unable to get the menu items. I shall be thankful if anyone tell me what are the changes I have to = make in the source file and resources file for including a File menu = with Open submenu ( as an example) using the resources editor in Dev C++. Can anybody send me the URL of some good online tutorials for Window = programming, preferably using Dev C++. With regards Ameer khan sm...@vs... |
|
From: Mac R. <re...@no...> - 2002-06-10 16:36:27
|
A few thoughts:
1. You can't shift bits in a float or double because not all bit patterns
are legal in the IEEE floating point representation. Also, shifting bits
in floats/doubles would move bits from the mantissa into the exponent, or
from the exponent into the mantissa, which is unlikely to be meaningful.
2. It may be that the shifts are taking place in a variable of the original
type. If that is true, then if you shift a 'char' value up by more than 8
bits, you will have shifted it entirely out of the temporary variable type.
Copy the value into a bigger int first, and then perform the shift.
Example from your code:
>short int mask =3D 65535;
>int zorro =3D mask + (mask << 15);
a. mask starts out filled : 0xFFFF
b. Then you shift it 15 bits over (instead of 16, which seems odd), which
shifts all of the bits out except for what used to be the least significant
bit: 0x8000
c. Now you add that to the original mask causing a roll off the high end:
0xFFFF + 0x8000 =3D 0x7FFF
d. Assignment to zorro yields : 0x00007FFF
As a general rule, I would recommend using 'long' explicitly rather than
'int' to avoid future portability problems. Since you are requiring 32
bits of storage, you should use a type that also has a practical guarantee
of 32 bits (I don't remember what the real standard requirement is, but
getting into the full checking is somewhat more involved). So if you
replaced the second line of code with the following, it *should* work:
long zorro =3D (long)mask + ((long)mask << 16);
or:
long zorro =3D mask;
zorro <<=3D 16;
zorro |=3D mask;
3. Also watch out for sign extension. If the result you are getting for
mask is not 0x00007FFF, then the compiler may be promoting the temporary
variables up to a larger size before doing the shifts, which will protect
your bits, but has other problems.
Example from your code:
>short int mask =3D 65535;
>int zorro =3D mask + (mask << 15);
Since mask and zorro are both signed, promotion will take place in signed
integers. The first major thing that I should have noticed sooner is that
you stored 65535 in a 'signed short int'. If you were to print out the
value of mask, you would *NOT* get 65535, you would get -1. By setting the
top bit, you have moved the value into the negative realm. So here's what
happened:
a. mask gets bit value 0xFFFF (-1)
b. During shifting, mask gets promoted to long so that bits are not lost.
Promotion *MUST* maintain the logical value (-1), so the compiler performs
sign extension. The temporary version of mask becomes the long version of
-1 : 0xFFFFFFFF
c. That temporary gets shifted up 15 bits : 0xFFFF8000
d. That gets added to another temporary, long, sign extended version of
mask : 0xFFFFFFFF + 0xFFFF8000 =3D 0xFFFF7FFFF (according to Windows=
Calculator)
The lesson here is that if you are going to play with bits and shifting,
*ALWAYS* work in unsigned variables :=20
unsigned short int mask =3D 65535; // I would prefer 0xFFFF for clarity...
unsigned long int zorro =3D mask + (mask << 16);
4. If you are just trying to get an array of bytes into a short, int, long,
float, or double, remember that memcpy is your friend.
memcpy(&MyLong, MyArrayOfBytes, 4); // array is already an address
or
memcpy(&MyLong, &MyStructureOfBytes, 4);
There are a *LOT* of things you have to keep in mind when playing this sort
of game. First, the memcpy method is hopelessly unportable. Byte ordering
inside multibyte variables changes on different machine types, so any given
ordering of bytes in the array will only work for certain types of
machines, but would at least work on those machines no matter which
compiler you used. Secondly, the memory packing of structures is undefined
by the standards, so different compilers are allowed to pack them pretty
much any way they want. The memcpy from a struct would only work for a
particular compiler, and might break in the next version.
If you're going to risk the major unportability problems of memcpy, you
might as well just drop to inline assembly and be explicit about the whole
thing. But there might be some meaningful reason. About the only thing
that comes to mind is if you had to work with some kind of storage API that
only accepted a pointer to chars, and you *KNEW* that both programs were
going to use the same memory layout...
Sample portable code, assuming that Bytes[4] has the most significant byte
in [0] and the least significant byte in [3]. This will work on *ANY*
machine or compiler. If the most/least significant bytes are in the other
order, run the loop the other way...
MyLong =3D 0;
for (int i=3D0; i<4; i++)
{
MyLong <<=3D 8;
MyLong |=3D MyArrayOfBytes[i];
}
I have to get back to work. Hopefully that made some kind of sense, and
was useful.
Mac
At 09:23 PM 6/8/02 +0200, Carlos Garc=EDa del Monte wrote:
>Hi:
>I have problem I want solve by bit shifts. Below I add the code (one of
>the many versions I tried) so you can see it and know better what I am
>searching. The thing I cannot do at any way is the shifting phase
>(obviously, if not the subject would have been another).
>I want take some bytes and put them in a variable with more than one
>byte of width. For example, a double or a long double variable.
>So I try unsigned char unschar; I make an struct with eight unschar, I
>assign the first eight bits to the first and shift it 7*8 places when
>assigning to double, the next 8 bits to the second, shifting eight bits
>less, and so on. But everyone except the last "warning shift is >=3D than
>the width of the type". The same if I try with unsigned int.
>If I try changing unchars by doubles, so they have the size I need for
>the shifts and that warning cannot appear, but then "error using double
>with int in binary >> operator". If I use with variables two doubles it
>says the same error "using double with double in >> binary operator".
>If I change to a struct with void varname:64; error because void is not
>"forgotten" (I don't remember the exact word), or there is no cast to
>int (in which case I have again the problem of shifting more than the
>width of the type, I suppose, in the trial of this it still says error
>because the buffer is void type or if I try int tal:64, then it exceeds
>its type).
>Finally, with temp as *unschar, the void_type{ int pues:64;}vacio;, I
>read with temp, assign it with (int) cast to pues and shift pues it
>reads it wrong and creates and error, windows has to close it.
>With long double it says no more than 64 width bitfields.
>Is there some way to do that and not having to be oneself who reads the
>bits?
>
>Here are the sizeofs of my computer:
>char: 1
>unsigned char: 1
>unsigned long int: 4
>short int: 2
>short: 2
>unsigned short int: 2
>int: 4
>float: 4
>double: 8
>unsigned char: 1
>unsigned int: 4
>long int: 4
>long double: 12
>
>The program:
>
>#include <iostream.h>
>#include <stdlib.h>
>#include <math.h>
>#include <fstream.h>
>#include <stdio.h>
>
>typedef struct new_doble{
>unsigned int dospri;
>unsigned int dosult;
>}doble;
>
>typedef struct signed_doble{
>int sig1;
>int sig2;
>}siged;
>
>typedef struct novo_dos{
>unsigned char uno;
>unsigned char dos; //These two are from a trial with double, trying to
>make a double with all 1 I get only 1.447e+09
>unsigned char tres;
>unsigned char cuatro;
>unsigned char cinco;
>unsigned char seis;
>unsigned char siete;
>unsigned char ocho;
>}dos;
>
>typedef struct complet{
>double every;
>};
>
>typedef struct char_type{
>unsigned char hype:64;
>}extra;
>
>typedef struct void_type{
>int pues:64;//This was void in the previous trials
>}vacio;
>
>int main()
>{
>doble pares;
>siged coplus;
>dos octos;
>complet all;
>int pri, ult;
>long double hala;
>double tal;
>double test =3D 747665.4576;
>unsigned char mascara =3D 255;
>short int mask =3D 65535;
>int zorro =3D mask + (mask << 15);
>double temp;
>unsigned char *pol;
>vacio nada;
>extra largo;
>fstream outFile;
>fstream inFile;
>FILE *fuera;
>FILE *dentro;
>
>cout << "zorro " << zorro << '\t' << mask << endl;
>outFile.open("shifting", ios::out);
>if(!outFile){
>cout << "shifting no abre" << endl;
>exit(1);
>}
>outFile << test;
>outFile.close();
>if((fuera =3D fopen("shifting", "r")) =3D=3D NULL){
>cout << "shiftin2 no abre" << endl;
>exit(1);
>}
>fseek(fuera, 0, SEEK_END);
>int size;
>size =3D ftell(fuera);
>rewind(fuera);
>int tanto =3D 55;
>while(!feof(fuera) && tanto >=3D 0){
>fread(pol, 1, 8, fuera);
>nada.pues=3D(int)pol;
>tal =3D nada.pues << tanto;
>tanto-=3D8;
>}
>fclose(fuera);
>
>cout << test << '\n' << tal;
>
>
>system("PAUSE");
>return 0;
>}
>
>
>_______________________________________________________________
>
>Don't miss the 2002 Sprint PCS Application Developer's Conference
>August 25-28 in Las Vegas -
http://devcon.sprintpcs.com/adp/index.cfm?source=3Dosdntextlink
>
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
-
_____________________________ /"\
Mac Reiter \ / ASCII Ribbon Campaign
Nomadics, Inc. X Against HTML Mail
re...@no... / \ (To join the campaign, simply use
this in your signature.)
=20
|