Re: Alternative COBOL "telco" source program
From: David Frank (dave_frank_at_hotmail.com)
Date: 05/30/04
- Next message: Donald Tees: "Re: win98 to XP"
- Previous message: LX-i: "Re: Alternative COBOL "telco" source program"
- In reply to: L Russ: "Re: Alternative COBOL "telco" source program"
- Next in thread: Michael Mattias: "Re: Alternative COBOL "telco" source program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 May 2004 06:56:29 GMT
"L Russ" <lruss@superlink.net> wrote in message
news:cfaeadf3.0405291901.250f89e@posting.google.com...
> "David Frank" <dave_frank@hotmail.com> wrote in message
> news:<7YCtc.32762$Ol3.8747@twister.tampabay.rr.com>...
>> > #include <string>
>> > #include <iostream>
>> > int main() {
>> > const std::string s = "The quick brown fox jumps over the lazy dog's
>> > back. ";
>> > std::cout << s.substr(0, s.find_last_not_of(" ")+1) << std::endl;
>> > return 0;
>> > }
>> >
>>
>> IMO, horrific syntax, but thats nothing new for C++ statements is it?
>
> It's actually quite beautiful.
>
>
>> and its sure not apparent to me that above outputs 2 lines, does it?
>
> No. You're right. I made a mistake when I wrote that code.
> Here is the corrected version, which I believe outputs exactly what
> your code does, including the trailing blanks which result from
> FORTRAN's fixed length strings. It's a little difficult to format
> things when I post. Google is unfriendly to long lines and tabs.
>
> #include <string>
> #include <iostream>
> int main() {
> const int lengthOfDavidFranksFortranString = 80;
> const std::string s1 = "The quick brown fox jumps over the lazy dog's
> back.";
> const std::string s = s1 +
> std::string(lengthOfDavidFranksFortranString-s1.length(),'
> ');
> const std::string::size_type lastNonBlank = s.find_last_not_of(" ");
> const std::string::size_type lastWordIndex =
>
> s.substr(0,lastNonBlank).find_last_of(" ");
> std::cout << s.substr(0, lastWordIndex+1) << "\n" <<
> s.substr(lastWordIndex+1) <<
> std::endl;
> return 0;
> }
>
> Does FORTRAN have support for a varying length string? I mean other
> than that thing that allows functions to be called with different
> length strings, which isn't the same thing. Wrong group to ask in?
>
I'm not sure its even part of the new F2003 standard, there is a
user-developed
varying length string module avail. that provides support.
I personally think using c-strings is all thats really needed if strings
must be
manipulated while holding on to trailing blanks and have my own simple
little
varying string module using c-strings that met challenges presented to
translate
various PL/I varying string examples several years back..
> BTW, you might find this link of interest. Someone who has some bad
> things to say about C++ and OOP, and some interesting things to say
> about software development in general. Can't say that I'm totally
> convinced by all of it, but some thought provoking stuff.
> http://www.leshatton.org/index.html
>
> LR
>
- Next message: Donald Tees: "Re: win98 to XP"
- Previous message: LX-i: "Re: Alternative COBOL "telco" source program"
- In reply to: L Russ: "Re: Alternative COBOL "telco" source program"
- Next in thread: Michael Mattias: "Re: Alternative COBOL "telco" source program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|