From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,51e0e3232c45c76c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-11 03:17:51 PST From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada References: <20010611.085009.1789366143.627@zamek.gda.pl> Subject: Re: converting - adasockets Date: Mon, 11 Jun 2001 05:17:49 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: Newsfeeds.com Message-ID: <3b2498c9$1_2@Newsfeeds.com> X-Authenticated-User: 143557362 X-Comments: This message was posted through Newsfeeds.com X-Comments2: IMPORTANT: Newsfeeds.com does not condone, nor support, spam or any illegal or copyrighted postings. X-Report: Report abuse to "abuse@Newsfeeds.com" Organization: Newsfeeds.com Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator-dallas!corp.newsfeeds.com Xref: archiver1.google.com comp.lang.ada:8527 Date: 2001-06-11T05:17:49-05:00 List-Id: Assuming the following Ada declarations, S : String [1 .. 10]; I : Integer; first you would need to declare a String subtype having the same length as the size of an Integer -- something like this: subtype Integer_Sized_String is String (1 .. Integer'size / Character'Size); : Then you would need to declare an unchecked conversion function, something like this: with Ada.Unchecked_Conversion; function To_Integer is new Ada.Unchecked_Conversion (Source => Integer_Sized_String, Target => Integer); With these additional declarations, you can now do the conversion like this: I := To_Integer (S (1 .. Integer_Sized_String'Length)); Now that this is done, I have a question for you -- assuming that sizeof (int) on your machine is 4, what are you going to do with the additional six characters of s? You may find it more useful to use the adasockets subprograms using Stream_Element_Array parameters instead of the string-oriented ones, because of their special treatment of CR and LF characters. "Micha� Nowikowski" wrote in message news:20010611.085009.1789366143.627@zamek.gda.pl... > Hello > > Im writting a program which reads some data from a socket > (i used adasockets). And i've problem with converting > this date from String to fg Integer. How could i do that. > In C it woul look like: > > char s[10]; > int i; > > i = *(int*)s; > > but in Ada? > > thanks in advance > Godfryd -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =-----