Thread: [Dev-C++] Re: Search and Replace Functions - Learning how to manipulate str ings
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: CARLSON, J. M. <CA...@st...> - 2003-06-26 05:27:32
|
To the new people especially,
all the =20 and =3D are not part of the program I submitted
Search and Replace Functions - Learning how to manipulate strings
and some simple string vectors (CARLSON, JAY MM1)
They may maybe space and tabs let see:
Here are some spaces
Here are some tabs
Here are some spaces and tabs
Maybe the =20 and =3D is a way to prevent straight code copying. Either way
you will have to strip out all the =20 and =3D to make the program work.
God Bless
Jay
Message: 6
From: "CARLSON, JAY MM1" <CA...@st...>
To: "'dev...@li...'"
<dev...@li...>
Date: Wed, 25 Jun 2003 12:56:39 -0800
Subject: [Dev-C++] Search and Replace Functions - Learning how to manipulate
strings
and some simple string vectors
// Search and Replace Function // Praise God for His Goodness and Mercy
// 22 June 2003 // Jay A Carlson
// Search and Replace Implementation and Testing
//
// Takes an input text and replacement text and makes it happen
// In the future I will have an input text file and a change file
// to end up with a new converted file.
//
// The specifications take the form of=20
// start delimiter, stop delimiter
// start and stop delimiters must be different although not check (yet)=20
// search and replace words inside of the start and stop delimiter=
s=20
// search - can be any text, number, word, or a phrase
// replace - can be any text, number, word, or phrase
// examples are as below:
// <> <search for this> <replace with this>;
// [] [search] [replace]
// <> <myArray[9]> <thisArray[10]>
// ^* ^std::cout<<test[5];* ^printf("test[3]");*
//
// Notice by being able to specify the start and stop delimiters for each=
=20
// search and replace you don't have to worry about nesting problems =
or=20
// escape sequence problems.
//
// abbreviations
// srt -- search and replace text
//
// personal notes: I did this for two reasons,
// 1. To learn how to manipulate C++ std::strings, and I am now just
getting
// the hang of it.
// 2. I actually need this for a specific purpose
//
// It could be used to replace >>>>>>> on email with ' ' or "".
//
// I am posting this on the internet for new people so they won't have =
to=20
// try and figure this all out from scratch. It took me a long time
and
// in general I know how to program but the std::library stuff is
taking
// me longer than I thought to learn.
//=20
// A REAL programmer probably wouldn't comment any of this because it i=
s
// probably obvious. I am going to comment the heck out of it to he=
lp
// new people and maybe myself.
//
// Because there are so many comments you might have to save two copies=
,
// one with the comments, and one with a lot of the comments stripped
out.
#include <iostream> // for std::cout
#include <string> // for std::string
#include <vector> // guess what - for vectors
// this is a function whose sole purpose in life is to get the word, or
words
// between the delimiters represented by the variables start and stop
// srt -- search and replace text
// debug -- a way of showing more or less information in a hurry
std::string getword_s(char start, char stop, std::string &srt, const bool
debug)=20
{
// \n - means put in a new line
// srt - same as above
if (debug) std::cout << "\nsrt =3D " << srt;=20
// I used unsigned int for first, last and len,
// I may have been able to use std::string::iterator instead
// but why would I want to type even more than I am now.
// I am sure for sorting iterators would be the way to go.
unsigned int first =3D srt.find_first_of(start) + 1;
unsigned int last =3D srt.find_first_of(stop) - 1;
unsigned int len =3D last - first + 1; // length of word(s) between
delimiters
// get the substring of srt, starting at position first (delimeter +1)
and
// go for len charachers. If len is larger than the string srt it
will
// just stop at the end.
std::string word =3D srt.substr(first, len);=20
// now that we got the word(s) we wanted out between the delimiters, i=
t
is=20
// time to remove that section so that we can work with the next part,=
if
// any. Once again the substring will stop at the end of the string,=20
// regaurdless of where length() tells it to stop.
srt =3D srt.substr(last + 2, srt.length());
// just so we can monitor to see that everything is working ok
if (debug) std::cout << "\nword(s) =3D " << word;
return word;
}
=20
// the name says it all =20
void search_and_replace(std::string &text, std::string &srt, const bool
debug) {
// I didn't want an accidental space to cause the program to glitch
// so in the next few lines I remove all spaces before delimiters.
// This also simplfied getting the delimiters
unsigned int eatwhite =3D srt.find_first_not_of(' ');
srt =3D srt.substr(eatwhite,srt.length());
char start =3D srt[0]; // the starting delimiter is now the first cha=
r in
srt =20
srt =3D srt.substr(1,srt.length());
eatwhite =3D srt.find_first_not_of(' ');
srt =3D srt.substr(eatwhite,srt.length());
char stop =3D srt[0]; // the ending delimiter is now the first char =
in
srt=20
// C++ uses 0 to start arrays and strings. It makes it easy to make F=
OR=20
// loops for(int i =3D 0; i < length; i++) {code here}
// You never want to end a loop on an i =3D=3D length there are two =
many
times=20
// when they don't match perfectly and you run the risk of going int=
o=20
// an infinite loop. (Okay maybe not so much for an integer, but a
float
// or double has a good chance that won't match perfectly. So it is
good
// programming practice to just use '<' instead of '=3D=3D' .
// Knowing that if you started the array at 1 you would
// have for(int i=3D1; i < length+1; i++) { code here } doesn't look=
to
bad,
// but when you get into multidimensional arrays, it gets harder to =
get
// the index number if you don't start at zero.=20
// Just learn to be standard...
=20
if (debug) { =20
// Once again, if we need to see if the output is correct.
std::cout << "\nStart Delimiter =3D " << start;
std::cout << "\nStop Delimiter =3D " << stop;
}
// remove the delimiter specifiers so we can look for the search=20
// and replace words
srt =3D srt.substr(2, srt.length()-1);=20
if (debug) std::cout << "\nsrt =3D " << srt << "\n";
// call the function getword_s to get the word(s) for the search part
std::string search =3D getword_s(start, stop, srt, debug);
if (debug) std::cout << "\n";
// call the function getword_s to get the word(s) for the replace part
std::string replace =3D getword_s(start, stop, srt, debug);
=20
if (debug) {
std::cout << "\n\nText: \n" << text;
std::cout << "\n\nThe word(s) to search for is/are : \"" << search=
<<
"\"";
std::cout << "\nThe word(s) to replace with is/are: \"" << replace =
<<
"\"";
std::cout << "\n";
}
// You better check to see that what your searching for is there befor=
e
// you try to replace it. If it is not there you can't replace it,
and
// your program will terminate before you can view any std::cout da=
ta.
if (text.length() > text.find(search)) {
//THIS IS IT - THE WHOLE PROGRAM IS MADE FOR THIS LINE TO DO ITS WORK
// Find the search word(s) in the text, and replace it with the word(=
s)
// stored in the variable replace, (not to be confused with the call =
of
the=20
// function text.replace()) for a length of the original word(s). =20
// Note the string will be expanded as necessary for the replacement =
to
fit. =20
// If the search word is not found, it cannot be replaced!!
text =3D text.replace(text.find(search), search.length(), replace)=
;
}
std::cout << "\n";
}
int main(void) {
bool debug =3D false; // toggle to see more details
std::string original =3D "I will be 40 next year.";
std::string new_text =3D original;
// Oh yeah - here I am experimenting with vectors of strings
// Vectors are almost like arrays, but better
std::vector<std::string>srt(4); // srt - search and replace text
// Test no match condition
srt[0] =3D " < > <35> <34>";
// Test replace with same size
srt[1] =3D " ( ) (40) (38)";
// Test replace with smaller size
srt[2] =3D "[ ] [ 38] []";
// Test replace with a bigger text
srt[3] =3D "[] [next] [a very old man next]";
=20
for(int i =3D 0; i < 4; i++) {
std::cout << "\nsrt =3D " << srt[i];
search_and_replace(new_text, srt[i], debug); =20
std::cout << "\nOriginal text: " << original;
std::cout << "\nNew text: " << new_text;
if (debug) {
std::cout << "\n\n\n\n";
system("pause");
}
else std::cout << "\n\n";
original =3D new_text;
}
if (!(debug)) system("pause");
return 0; =20
}
// I hoped you like the way I use debug to show whats going on
// I am finally getting the hang of the STL .. well a little bit anyway.
// It took me forever to get some of the syntax right, but now learning c=
an=20
// happen. And if its too late to learn there is alway cut and paste.
// Praise God for His Goodness and Mercy
// Jay A. Carlson
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...]
Sent: Monday, June 23, 2003 9:30 AM
To: dev...@li...
Subject: Dev-cpp-users digest, Vol 1 #1511 - 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: Comment Delimiters (Damien .)
2. RE: Comment Delimiters (Per Westermark)
3. Re: Comment Delimiters (Per Westermark)
4. Re: Comment Delimiters (Daniel Glenfield)
5. Re: WRITING TO SERIAL PORT (Daniel Glenfield)
6. Re: FREE download: a HOW-TO use wxWindows with Dev-C++ (Brian
Ackermann)
-- __--__--
Message: 1
From: "Damien ." <g_...@ho...>
To: dev...@li...
Subject: Re: [Dev-C++] Comment Delimiters
Date: Mon, 23 Jun 2003 06:41:24 -0400
Guys, How exactly does '#if 0' ...#endif work? I assumed that the=20
preprocessor would skip the statements until it reached the #endif. =20
However, when I tried to compile the code(with gcc 3.2.2) below , i get =
a=20
"missing terminator character ' error" . It seems as though the code ins=
ide
of an #if 0...#endif statement must be C/C++ accurate. It is easy fixed=20
with a /*... */ .Care to elaborate....?
/* IfZero.c */
#include <stdio.h>
int main(void)
{
#if 0
This line should not be worried about. I'm quite sure it will *not* be =20
included.
#endif
printf("...");
return 0;
}
----Original Message Follows----
From: "Daniel Glenfield" <sp...@ho...>
To: or...@vp..., dev...@li...
Subject: Re: [Dev-C++] Comment Delimiters
Date: Mon, 23 Jun 2003 09:16:30 +0100
Agreed. #if 0 ..#endif is a great way of doing it.
>From: OROSZI Bal=E1zs <or...@vp...>
>To: dev...@li...
>Subject: Re: [Dev-C++] Comment Delimiters
>Date: Mon, 23 Jun 2003 10:01:54 +0200
>
>Andr=E9 Mac=E1rio Barros wrote:
>>Dear Users,
>>
>> Suppose you can=B4t use the /* and */ comment delimiters to put in
comments
>>an area of a code in C++.
>> If I use the // command, must I put them in each line of this piece
of
>>code?
>> Is there another way?
>
>There is a quick way:
>
>#if 0
>...
>#endif
>
>Because "0" is "false", #if 0 can be considered like if (false){...}, wh=
ich
>will in fact, never execute. So all code, with or without comments, will=
=20
>not be parsed by the C preprocessor there.
>
>This approach is also better, because /* */ comments cannot be nested.
>
>--
>Greetings,
> Bal=E1zs
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: INetU
>Attention Web Developers & Consultants: Become An INetU Hosting Partner.
>Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
>INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnmob=
ile
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*=20
http://join.msn.com/?page=3Dfeatures/junkmail
-- __--__--
Message: 2
Date: Mon, 23 Jun 2003 13:45:45 +0200 (CEST)
From: Per Westermark <pw...@ia...>
To: Ioannis Vranos <iv...@em...>
cc: Dev-C++ Mailing List <dev...@li...>
Subject: RE: [Dev-C++] Comment Delimiters
Yes, it is always good to have definned coding rules for new projects,
but:
1 - /* */ doesn't support nesting except for some compilers.
2 - it is not uncommon for a project to inherrit code, and that code migh=
t
use /* */ or might even be in C.
The only two safe methods of deactivating a large block of code is to
either delete the lines, or to #ifdef them. With good source control, the
code delete is preferable since it's WYSIWYG. However, a lot of people
doesn't use CVS or SourceSafe et. al at home, and then it is very easy to
permanently loose deleted code lines.
/Per W
On Mon, 23 Jun 2003, Ioannis Vranos wrote:
> > -----Original Message-----
> > From: Per Westermark [mailto:pw...@ia...] On Behalf
> > Of Per Westermark
> > Sent: Monday, June 23, 2003 11:56 AM
> > To: Ioannis Vranos
> > Cc: 'Dev-Cpp-Users'
> > Subject: RE: [Dev-C++] Comment Delimiters
> >
> >
> > Often the one asking a question don't really know exactly
> > what they want -
> > or at least doesn't specify it clearly enough.
> >
> > Yes, multiline comments should of course use /* ... */ but
> > very often when
> > someone gets bothered about commenting away a large number of
> > lines, they
> > are not thinking about a big block-comment, but a large block
> > of unwanted
> > code.
>
>
> I did not understand what you mean but a very good commenting style is
this:
>
>
> For comments use only //.
>
> Use /* */ only for debugging purposes.
>
>
>
>
> Ioannis Vranos
>
> * Programming pages: http://www.noicys.freeurl.com
> * Alternative URL 1: http://run.to/noicys
> * Alternative URL 2: http://www.noicys.cjb.net
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission=
!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
-- __--__--
Message: 3
Date: Mon, 23 Jun 2003 13:57:42 +0200 (CEST)
From: Per Westermark <pw...@ia...>
To: "Damien ." <g_...@ho...>
cc: dev...@li...
Subject: Re: [Dev-C++] Comment Delimiters
Normally you can put just about anything within the #ifdef/#endif or
#if/#endif block - except that you should be a bit carefull about lines
that ends with a \ or lines that start with #.
Even in a undefined block, the preprocessor will expect \ at the end of
the line to mean a line-continuation with, if the next source line
contains the #endif will spell trouble.
Since the compiler supports nested #ifdef constructs, any #ifdef, #if,
#else, #endif etc. might seriously affect the size of the deactivated
block.
/Per W
On Mon, 23 Jun 2003, Damien . wrote:
> Guys, How exactly does '#if 0' ...#endif work? I assumed that the
> preprocessor would skip the statements until it reached the #endif.
> However, when I tried to compile the code(with gcc 3.2.2) below , i ge=
t =3D
a
> "missing terminator character ' error" . It seems as though the code i=
ns=3D
ide
> of an #if 0...#endif statement must be C/C++ accurate. It is easy fixe=
d
> with a /*... */ .Care to elaborate....?
> /* IfZero.c */
> #include <stdio.h>
> int main(void)
> {
> #if 0
> This line should not be worried about. I'm quite sure it will *not* be
> included.
> #endif
> printf("...");
> return 0;
> }
>
> ----Original Message Follows----
> From: "Daniel Glenfield" <sp...@ho...>
> To: or...@vp..., dev...@li...
> Subject: Re: [Dev-C++] Comment Delimiters
> Date: Mon, 23 Jun 2003 09:16:30 +0100
>
> Agreed. #if 0 ..#endif is a great way of doing it.
>
>
> >From: OROSZI Bal=3DE1zs <or...@vp...>
> >To: dev...@li...
> >Subject: Re: [Dev-C++] Comment Delimiters
> >Date: Mon, 23 Jun 2003 10:01:54 +0200
> >
> >Andr=3DE9 Mac=3DE1rio Barros wrote:
> >>Dear Users,
> >>
> >>=3D09Suppose you can=3DB4t use the /* and */ comment delimiters to pu=
t in c=3D
omments
> >>an area of a code in C++.
> >>=3D09If I use the // command, must I put them in each line of this pi=
ece =3D
of
> >>code?
> >> Is there another way?
> >
> >There is a quick way:
> >
> >#if 0
> >...
> >#endif
> >
> >Because "0" is "false", #if 0 can be considered like if (false){...}, =
wh=3D
ich
> >will in fact, never execute. So all code, with or without comments, wi=
ll
> >not be parsed by the C preprocessor there.
> >
> >This approach is also better, because /* */ comments cannot be nested.
> >
> >--
> >Greetings,
> > Bal=3DE1zs
> >
> >
> >
> >-------------------------------------------------------
> >This SF.Net email is sponsored by: INetU
> >Attention Web Developers & Consultants: Become An INetU Hosting Partne=
r.
> >Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commissio=
n!
> >INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> _________________________________________________________________
> On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnm=
ob=3D
ile
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission=
!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> _________________________________________________________________
> The new MSN 8: advanced junk mail protection and 2 months FREE*
> http://join.msn.com/?page=3D3Dfeatures/junkmail
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission=
!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
-- __--__--
Message: 4
From: "Daniel Glenfield" <sp...@ho...>
To: g_...@ho..., dev...@li...
Subject: Re: [Dev-C++] Comment Delimiters
Date: Mon, 23 Jun 2003 13:21:14 +0100
#if 0
cout << "This code will not be compiled, but I don't know if it needs to =
be=20
syntactically correct or not. Probably does" << endl;
#endif
Yes I know I've forgotten to #include the iostream header.
>From: "Damien ." <g_...@ho...>
>To: dev...@li...
>Subject: Re: [Dev-C++] Comment Delimiters
>Date: Mon, 23 Jun 2003 06:41:24 -0400
>
>Guys, How exactly does '#if 0' ...#endif work? I assumed that the=20
>preprocessor would skip the statements until it reached the #endif. =20
>However, when I tried to compile the code(with gcc 3.2.2) below , i get=
a=20
>"missing terminator character ' error" . It seems as though the code=20
>inside of an #if 0...#endif statement must be C/C++ accurate. It is eas=
y=20
>fixed with a /*... */ .Care to elaborate....?
>/* IfZero.c */
>#include <stdio.h>
>int main(void)
>{
>#if 0
>This line should not be worried about. I'm quite sure it will *not* be =20
>included.
>#endif
>printf("...");
>return 0;
>}
>
>----Original Message Follows----
>From: "Daniel Glenfield" <sp...@ho...>
>To: or...@vp..., dev...@li...
>Subject: Re: [Dev-C++] Comment Delimiters
>Date: Mon, 23 Jun 2003 09:16:30 +0100
>
>Agreed. #if 0 ..#endif is a great way of doing it.
>
>
>>From: OROSZI Bal=E1zs <or...@vp...>
>>To: dev...@li...
>>Subject: Re: [Dev-C++] Comment Delimiters
>>Date: Mon, 23 Jun 2003 10:01:54 +0200
>>
>>Andr=E9 Mac=E1rio Barros wrote:
>>>Dear Users,
>>>
>>> Suppose you can=B4t use the /* and */ comment delimiters to put
in=20
>>>comments
>>>an area of a code in C++.
>>> If I use the // command, must I put them in each line of this piece
of
>>>code?
>>> Is there another way?
>>
>>There is a quick way:
>>
>>#if 0
>>...
>>#endif
>>
>>Because "0" is "false", #if 0 can be considered like if (false){...},=20
>>which will in fact, never execute. So all code, with or without comment=
s,=20
>>will not be parsed by the C preprocessor there.
>>
>>This approach is also better, because /* */ comments cannot be nested.
>>
>>--
>>Greetings,
>> Bal=E1zs
>>
>>
>>
>>-------------------------------------------------------
>>This SF.Net email is sponsored by: INetU
>>Attention Web Developers & Consultants: Become An INetU Hosting Partner.
>>Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission=
!
>>INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
>>_______________________________________________
>>Dev-cpp-users mailing list
>>Dev...@li...
>>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>_________________________________________________________________
>On the move? Get Hotmail on your mobile phone=20
>http://www.msn.co.uk/msnmobile
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: INetU
>Attention Web Developers & Consultants: Become An INetU Hosting Partner.
>Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
>INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>_________________________________________________________________
>The new MSN 8: advanced junk mail protection and 2 months FREE*=20
>http://join.msn.com/?page=3Dfeatures/junkmail
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: INetU
>Attention Web Developers & Consultants: Become An INetU Hosting Partner.
>Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
>INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
Find a cheaper internet access deal - choose one to suit you.=20
http://www.msn.co.uk/internetaccess
-- __--__--
Message: 5
From: "Daniel Glenfield" <sp...@ho...>
To: MDo...@OL..., dev...@li...
Subject: Re: [Dev-C++] WRITING TO SERIAL PORT
Date: Mon, 23 Jun 2003 13:28:07 +0100
I'm not entirely sure of the syntax but...
In DOS (command prompt) you can do
nmake DebugBuild > LPT1
to send output of the DebugBuild "build" to the printer attached to LPT1.=
=20
I'm not sure about how you could tie this in with your project though...
>From: Dondolo Mpho <MDo...@OL...>
>To: dev...@li...
>Subject: [Dev-C++] WRITING TO SERIAL PORT
>Date: Mon, 23 Jun 2003 10:23:36 +0200
>
>Hi all,
>
>I have been playing around with streams and need the following help.
>I am able to print my files to our network printer and also write them t=
o
>specific network drives.
>How do I write a device in one of my ports...eg, serial port
>consider this code as an example.
>
>
>
>ofstream create(" \\omcwca054\\HPLJ5000 <file://\\omcwca054\\HPLJ5000> "=
)
>cout<<"The following will be printed to on lazer jet printer";
>create<<" Mpho Dondolo\n"
> <<" 45 Durban Ridge\n"
> <<"Tyger Valley\n";
>create.close();
>
>I want to write to my matrix display board that is connected to my seria=
l
>port.
>
>NB!!!! Please do not flip if have not supplied sufficient info. ( last i=
=20
>did
>that, some guy almost had a heart attack) I am still new at this game
>
>
_________________________________________________________________
Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
-- __--__--
Message: 6
Date: Mon, 23 Jun 2003 12:26:20 -0500
From: Brian Ackermann <bri...@gm...>
CC: dev...@li...
Subject: Re: [Dev-C++] FREE download: a HOW-TO use wxWindows with Dev-C++
This is a multi-part message in MIME format.
--------------000300010007070605010009
Content-Type: text/plain; charset=3Dus-ascii; format=3Dflowed
Content-Transfer-Encoding: 7bit
Well, here's the part that works...
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
bja3622@ANN /c/wx/samples/minimal
$ make -f makefile.unx c++ -c `wx-config --cxxflags` -o minimal.o=20
minimal.cpp
c++ -o minimal minimal.o `wx-config --libs`
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
and my flags look like this ::
bja3622@ANN /c/wx/samples/minimal
$ wx-config --cxxflags
-I/usr/local/lib/wx/include/mswd-2.5 -D__WXDEBUG__ -D__WXMSW__ -mthreads=20
-fno-pcc-struct-return
bja3622@ANN /c/wx/samples/minimal
$ wx-config --libs
-L/usr/local/lib -Wl,--subsystem,windows -mwindows -mthreads =20
/usr/local/lib/libwxmsw250d.a -ltiff -lrpcrt4 -loleaut32 -lole32 -luuid=20
-lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -ladvapi32 -lwsock32
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
And this is the make output from Dev-Cpp
$ make -f makefile.win
g++.exe -c minimal.cpp -o minimal.o -I"C:/Dev-Cpp/include/c++" =20
-I"C:/Dev-Cpp/include/c++/mingw32" -I"C:/Dev-Cpp/include/c++/backward" =20
-I"C:/Dev-Cpp/include" -I"C:/msys/1.0/local/include" =20
-I"C:/msys/1.0/local/lib/wx/include/mswd-2.5" -D__WXDEBUG__ =20
-D__WXMSW__ -D__GNUWIN32__ -mthreads -fno-pcc-struct-return=20
windres.exe -i Project2_private.rc -I rc -o Project2_private.res -O=20
coff --include-dir C:/msys/1.0/local/include
g++.exe minimal.o Project2_private.res -o "Project2.exe"=20
-L"C:/Dev-Cpp/lib" -L"C:/msys/1.0/local/lib/wx" -mwindows=20
-Wl,--subsystem,windows -mwindows -mthreads =20
C:/wx/mswd/lib/libwxmsw250d.a -ltiff -lrpcrt4 -loleaut32 -lole32 =20
-luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 =20
-ladvapi32 -lwsock32
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D
Aside from the inclusion of -D__GNUWIN32__ the compiler options are the=20
same (plus a bunch of include directories, maybe relevant, maybe not...I=20
don't know how to tell)
Same story with the libs too...the only difference is the -L"..." flags..=
..
I guess the culprit must be right here....
Brian Ackermann
Yeoh HS wrote:
>----- Original Message -----
>From: "Brian Ackermann" <bri...@gm...>
>To: <dev...@li...>
>Sent: Friday, June 20, 2003 10:14 PM
>Subject: Re: [Dev-C++] FREE download: a HOW-TO use wxWindows with Dev-C+=
+
>
>
> =20
>
>>Yeoh, and others
>>
>>I've done according to the instructions in this document, and,
>>unfortunately I get the same problem I had gotten before. The
>>application compiles (but Dev-Cpp cannot run it, I must go through the
>>explorer for that...) but when it executes, immediately it genera...
[truncated message content] |
|
From: Per W. <pw...@ia...> - 2003-06-26 05:47:55
|
It's the result of your mail program configured to sending MIME Quoted
Printable format. Please turn off before posting code. Some mail readers
really hates this format...
/Per W
On Wed, 25 Jun 2003, CARLSON, JAY MM1 wrote:
> To the new people especially,
> all the =20 and =3D are not part of the program I submitted
>
> Search and Replace Functions - Learning how to manipulate strings
> and some simple string vectors (CARLSON, JAY MM1)
>
>
> They may maybe space and tabs let see:
> Here are some spaces
>
>
> Here are some tabs
>
>
> Here are some spaces and tabs
>
>
> Maybe the =20 and =3D is a way to prevent straight code copying. Either way
> you will have to strip out all the =20 and =3D to make the program work.
> God Bless
> Jay
>
>
>
>
> Message: 6
> From: "CARLSON, JAY MM1" <CA...@st...>
> To: "'dev...@li...'"
> <dev...@li...>
> Date: Wed, 25 Jun 2003 12:56:39 -0800
> Subject: [Dev-C++] Search and Replace Functions - Learning how to manipulate
> strings
> and some simple string vectors
>
> // Search and Replace Function // Praise God for His Goodness and Mercy
> // 22 June 2003 // Jay A Carlson
>
> // Search and Replace Implementation and Testing
> //
> // Takes an input text and replacement text and makes it happen
> // In the future I will have an input text file and a change file
> // to end up with a new converted file.
> //
> // The specifications take the form of=20
> // start delimiter, stop delimiter
> // start and stop delimiters must be different although not check (yet)=20
> // search and replace words inside of the start and stop delimiter=
> s=20
> // search - can be any text, number, word, or a phrase
> // replace - can be any text, number, word, or phrase
> // examples are as below:
> // <> <search for this> <replace with this>;
> // [] [search] [replace]
> // <> <myArray[9]> <thisArray[10]>
> // ^* ^std::cout<<test[5];* ^printf("test[3]");*
> //
> // Notice by being able to specify the start and stop delimiters for each=
> =20
> // search and replace you don't have to worry about nesting problems =
> or=20
> // escape sequence problems.
> //
> // abbreviations
> // srt -- search and replace text
> //
> // personal notes: I did this for two reasons,
> // 1. To learn how to manipulate C++ std::strings, and I am now just
> getting
> // the hang of it.
> // 2. I actually need this for a specific purpose
> //
> // It could be used to replace >>>>>>> on email with ' ' or "".
> //
> // I am posting this on the internet for new people so they won't have =
> to=20
> // try and figure this all out from scratch. It took me a long time
> and
> // in general I know how to program but the std::library stuff is
> taking
> // me longer than I thought to learn.
> //=20
> // A REAL programmer probably wouldn't comment any of this because it i=
> s
> // probably obvious. I am going to comment the heck out of it to he=
> lp
> // new people and maybe myself.
> //
> // Because there are so many comments you might have to save two copies=
> ,
> // one with the comments, and one with a lot of the comments stripped
> out.
>
> #include <iostream> // for std::cout
> #include <string> // for std::string
> #include <vector> // guess what - for vectors
>
> // this is a function whose sole purpose in life is to get the word, or
> words
> // between the delimiters represented by the variables start and stop
> // srt -- search and replace text
> // debug -- a way of showing more or less information in a hurry
> std::string getword_s(char start, char stop, std::string &srt, const bool
> debug)=20
> {
> // \n - means put in a new line
> // srt - same as above
> if (debug) std::cout << "\nsrt =3D " << srt;=20
> // I used unsigned int for first, last and len,
> // I may have been able to use std::string::iterator instead
> // but why would I want to type even more than I am now.
> // I am sure for sorting iterators would be the way to go.
> unsigned int first =3D srt.find_first_of(start) + 1;
> unsigned int last =3D srt.find_first_of(stop) - 1;
> unsigned int len =3D last - first + 1; // length of word(s) between
> delimiters
> // get the substring of srt, starting at position first (delimeter +1)
> and
> // go for len charachers. If len is larger than the string srt it
> will
> // just stop at the end.
> std::string word =3D srt.substr(first, len);=20
> // now that we got the word(s) we wanted out between the delimiters, i=
> t
> is=20
> // time to remove that section so that we can work with the next part,=
> if
>
> // any. Once again the substring will stop at the end of the string,=20
> // regaurdless of where length() tells it to stop.
> srt =3D srt.substr(last + 2, srt.length());
> // just so we can monitor to see that everything is working ok
> if (debug) std::cout << "\nword(s) =3D " << word;
> return word;
> }
> =20
> // the name says it all =20
> void search_and_replace(std::string &text, std::string &srt, const bool
> debug) {
> // I didn't want an accidental space to cause the program to glitch
> // so in the next few lines I remove all spaces before delimiters.
> // This also simplfied getting the delimiters
> unsigned int eatwhite =3D srt.find_first_not_of(' ');
> srt =3D srt.substr(eatwhite,srt.length());
> char start =3D srt[0]; // the starting delimiter is now the first cha=
> r in
> srt =20
> srt =3D srt.substr(1,srt.length());
> eatwhite =3D srt.find_first_not_of(' ');
> srt =3D srt.substr(eatwhite,srt.length());
> char stop =3D srt[0]; // the ending delimiter is now the first char =
> in
> srt=20
> // C++ uses 0 to start arrays and strings. It makes it easy to make F=
> OR=20
> // loops for(int i =3D 0; i < length; i++) {code here}
> // You never want to end a loop on an i =3D=3D length there are two =
> many
> times=20
> // when they don't match perfectly and you run the risk of going int=
> o=20
> // an infinite loop. (Okay maybe not so much for an integer, but a
> float
> // or double has a good chance that won't match perfectly. So it is
> good
> // programming practice to just use '<' instead of '=3D=3D' .
> // Knowing that if you started the array at 1 you would
> // have for(int i=3D1; i < length+1; i++) { code here } doesn't look=
> to
> bad,
> // but when you get into multidimensional arrays, it gets harder to =
> get
>
> // the index number if you don't start at zero.=20
> // Just learn to be standard...
> =20
> if (debug) { =20
> // Once again, if we need to see if the output is correct.
> std::cout << "\nStart Delimiter =3D " << start;
> std::cout << "\nStop Delimiter =3D " << stop;
> }
> // remove the delimiter specifiers so we can look for the search=20
> // and replace words
> srt =3D srt.substr(2, srt.length()-1);=20
> if (debug) std::cout << "\nsrt =3D " << srt << "\n";
> // call the function getword_s to get the word(s) for the search part
> std::string search =3D getword_s(start, stop, srt, debug);
> if (debug) std::cout << "\n";
> // call the function getword_s to get the word(s) for the replace part
> std::string replace =3D getword_s(start, stop, srt, debug);
> =20
> if (debug) {
> std::cout << "\n\nText: \n" << text;
> std::cout << "\n\nThe word(s) to search for is/are : \"" << search=
> <<
> "\"";
> std::cout << "\nThe word(s) to replace with is/are: \"" << replace =
> <<
> "\"";
> std::cout << "\n";
> }
> // You better check to see that what your searching for is there befor=
> e
> // you try to replace it. If it is not there you can't replace it,
> and
> // your program will terminate before you can view any std::cout da=
> ta.
> if (text.length() > text.find(search)) {
> //THIS IS IT - THE WHOLE PROGRAM IS MADE FOR THIS LINE TO DO ITS WORK
> // Find the search word(s) in the text, and replace it with the word(=
> s)
> // stored in the variable replace, (not to be confused with the call =
> of
> the=20
> // function text.replace()) for a length of the original word(s). =20
> // Note the string will be expanded as necessary for the replacement =
> to
> fit. =20
> // If the search word is not found, it cannot be replaced!!
> text =3D text.replace(text.find(search), search.length(), replace)=
> ;
> }
> std::cout << "\n";
> }
>
> int main(void) {
> bool debug =3D false; // toggle to see more details
> std::string original =3D "I will be 40 next year.";
> std::string new_text =3D original;
> // Oh yeah - here I am experimenting with vectors of strings
> // Vectors are almost like arrays, but better
> std::vector<std::string>srt(4); // srt - search and replace text
> // Test no match condition
> srt[0] =3D " < > <35> <34>";
> // Test replace with same size
> srt[1] =3D " ( ) (40) (38)";
> // Test replace with smaller size
> srt[2] =3D "[ ] [ 38] []";
> // Test replace with a bigger text
> srt[3] =3D "[] [next] [a very old man next]";
> =20
> for(int i =3D 0; i < 4; i++) {
> std::cout << "\nsrt =3D " << srt[i];
> search_and_replace(new_text, srt[i], debug); =20
> std::cout << "\nOriginal text: " << original;
> std::cout << "\nNew text: " << new_text;
> if (debug) {
> std::cout << "\n\n\n\n";
> system("pause");
> }
> else std::cout << "\n\n";
> original =3D new_text;
> }
> if (!(debug)) system("pause");
> return 0; =20
> }
>
> // I hoped you like the way I use debug to show whats going on
>
> // I am finally getting the hang of the STL .. well a little bit anyway.
> // It took me forever to get some of the syntax right, but now learning c=
> an=20
> // happen. And if its too late to learn there is alway cut and paste.
> // Praise God for His Goodness and Mercy
> // Jay A. Carlson
>
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...]
> Sent: Monday, June 23, 2003 9:30 AM
> To: dev...@li...
> Subject: Dev-cpp-users digest, Vol 1 #1511 - 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: Comment Delimiters (Damien .)
> 2. RE: Comment Delimiters (Per Westermark)
> 3. Re: Comment Delimiters (Per Westermark)
> 4. Re: Comment Delimiters (Daniel Glenfield)
> 5. Re: WRITING TO SERIAL PORT (Daniel Glenfield)
> 6. Re: FREE download: a HOW-TO use wxWindows with Dev-C++ (Brian
> Ackermann)
>
> -- __--__--
>
> Message: 1
> From: "Damien ." <g_...@ho...>
> To: dev...@li...
> Subject: Re: [Dev-C++] Comment Delimiters
> Date: Mon, 23 Jun 2003 06:41:24 -0400
>
> Guys, How exactly does '#if 0' ...#endif work? I assumed that the=20
> preprocessor would skip the statements until it reached the #endif. =20
> However, when I tried to compile the code(with gcc 3.2.2) below , i get =
> a=20
> "missing terminator character ' error" . It seems as though the code ins=
> ide
>
> of an #if 0...#endif statement must be C/C++ accurate. It is easy fixed=20
> with a /*... */ .Care to elaborate....?
> /* IfZero.c */
> #include <stdio.h>
> int main(void)
> {
> #if 0
> This line should not be worried about. I'm quite sure it will *not* be =20
> included.
> #endif
> printf("...");
> return 0;
> }
>
> ----Original Message Follows----
> From: "Daniel Glenfield" <sp...@ho...>
> To: or...@vp..., dev...@li...
> Subject: Re: [Dev-C++] Comment Delimiters
> Date: Mon, 23 Jun 2003 09:16:30 +0100
>
> Agreed. #if 0 ..#endif is a great way of doing it.
>
>
> >From: OROSZI Bal=E1zs <or...@vp...>
> >To: dev...@li...
> >Subject: Re: [Dev-C++] Comment Delimiters
> >Date: Mon, 23 Jun 2003 10:01:54 +0200
> >
> >Andr=E9 Mac=E1rio Barros wrote:
> >>Dear Users,
> >>
> >> Suppose you can=B4t use the /* and */ comment delimiters to put in
> comments
> >>an area of a code in C++.
> >> If I use the // command, must I put them in each line of this piece
> of
> >>code?
> >> Is there another way?
> >
> >There is a quick way:
> >
> >#if 0
> >...
> >#endif
> >
> >Because "0" is "false", #if 0 can be considered like if (false){...}, wh=
> ich
>
> >will in fact, never execute. So all code, with or without comments, will=
> =20
> >not be parsed by the C preprocessor there.
> >
> >This approach is also better, because /* */ comments cannot be nested.
> >
> >--
> >Greetings,
> > Bal=E1zs
> >
> >
> >
> >-------------------------------------------------------
> >This SF.Net email is sponsored by: INetU
> >Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> >Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> >INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> _________________________________________________________________
> On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnmob=
> ile
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> _________________________________________________________________
> The new MSN 8: advanced junk mail protection and 2 months FREE*=20
> http://join.msn.com/?page=3Dfeatures/junkmail
>
>
>
> -- __--__--
>
> Message: 2
> Date: Mon, 23 Jun 2003 13:45:45 +0200 (CEST)
> From: Per Westermark <pw...@ia...>
> To: Ioannis Vranos <iv...@em...>
> cc: Dev-C++ Mailing List <dev...@li...>
> Subject: RE: [Dev-C++] Comment Delimiters
>
> Yes, it is always good to have definned coding rules for new projects,
> but:
> 1 - /* */ doesn't support nesting except for some compilers.
> 2 - it is not uncommon for a project to inherrit code, and that code migh=
> t
> use /* */ or might even be in C.
>
> The only two safe methods of deactivating a large block of code is to
> either delete the lines, or to #ifdef them. With good source control, the
> code delete is preferable since it's WYSIWYG. However, a lot of people
> doesn't use CVS or SourceSafe et. al at home, and then it is very easy to
> permanently loose deleted code lines.
>
> /Per W
>
> On Mon, 23 Jun 2003, Ioannis Vranos wrote:
>
> > > -----Original Message-----
> > > From: Per Westermark [mailto:pw...@ia...] On Behalf
> > > Of Per Westermark
> > > Sent: Monday, June 23, 2003 11:56 AM
> > > To: Ioannis Vranos
> > > Cc: 'Dev-Cpp-Users'
> > > Subject: RE: [Dev-C++] Comment Delimiters
> > >
> > >
> > > Often the one asking a question don't really know exactly
> > > what they want -
> > > or at least doesn't specify it clearly enough.
> > >
> > > Yes, multiline comments should of course use /* ... */ but
> > > very often when
> > > someone gets bothered about commenting away a large number of
> > > lines, they
> > > are not thinking about a big block-comment, but a large block
> > > of unwanted
> > > code.
> >
> >
> > I did not understand what you mean but a very good commenting style is
> this:
> >
> >
> > For comments use only //.
> >
> > Use /* */ only for debugging purposes.
> >
> >
> >
> >
> > Ioannis Vranos
> >
> > * Programming pages: http://www.noicys.freeurl.com
> > * Alternative URL 1: http://run.to/noicys
> > * Alternative URL 2: http://www.noicys.cjb.net
> >
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: INetU
> > Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission=
> !
> > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
>
>
>
> -- __--__--
>
> Message: 3
> Date: Mon, 23 Jun 2003 13:57:42 +0200 (CEST)
> From: Per Westermark <pw...@ia...>
> To: "Damien ." <g_...@ho...>
> cc: dev...@li...
> Subject: Re: [Dev-C++] Comment Delimiters
>
> Normally you can put just about anything within the #ifdef/#endif or
> #if/#endif block - except that you should be a bit carefull about lines
> that ends with a \ or lines that start with #.
>
> Even in a undefined block, the preprocessor will expect \ at the end of
> the line to mean a line-continuation with, if the next source line
> contains the #endif will spell trouble.
>
> Since the compiler supports nested #ifdef constructs, any #ifdef, #if,
> #else, #endif etc. might seriously affect the size of the deactivated
> block.
>
> /Per W
>
> On Mon, 23 Jun 2003, Damien . wrote:
>
> > Guys, How exactly does '#if 0' ...#endif work? I assumed that the
> > preprocessor would skip the statements until it reached the #endif.
> > However, when I tried to compile the code(with gcc 3.2.2) below , i ge=
> t =3D
> a
> > "missing terminator character ' error" . It seems as though the code i=
> ns=3D
> ide
> > of an #if 0...#endif statement must be C/C++ accurate. It is easy fixe=
> d
> > with a /*... */ .Care to elaborate....?
> > /* IfZero.c */
> > #include <stdio.h>
> > int main(void)
> > {
> > #if 0
> > This line should not be worried about. I'm quite sure it will *not* be
> > included.
> > #endif
> > printf("...");
> > return 0;
> > }
> >
> > ----Original Message Follows----
> > From: "Daniel Glenfield" <sp...@ho...>
> > To: or...@vp..., dev...@li...
> > Subject: Re: [Dev-C++] Comment Delimiters
> > Date: Mon, 23 Jun 2003 09:16:30 +0100
> >
> > Agreed. #if 0 ..#endif is a great way of doing it.
> >
> >
> > >From: OROSZI Bal=3DE1zs <or...@vp...>
> > >To: dev...@li...
> > >Subject: Re: [Dev-C++] Comment Delimiters
> > >Date: Mon, 23 Jun 2003 10:01:54 +0200
> > >
> > >Andr=3DE9 Mac=3DE1rio Barros wrote:
> > >>Dear Users,
> > >>
> > >>=3D09Suppose you can=3DB4t use the /* and */ comment delimiters to pu=
> t in c=3D
> omments
> > >>an area of a code in C++.
> > >>=3D09If I use the // command, must I put them in each line of this pi=
> ece =3D
> of
> > >>code?
> > >> Is there another way?
> > >
> > >There is a quick way:
> > >
> > >#if 0
> > >...
> > >#endif
> > >
> > >Because "0" is "false", #if 0 can be considered like if (false){...}, =
> wh=3D
> ich
> > >will in fact, never execute. So all code, with or without comments, wi=
> ll
> > >not be parsed by the C preprocessor there.
> > >
> > >This approach is also better, because /* */ comments cannot be nested.
> > >
> > >--
> > >Greetings,
> > > Bal=3DE1zs
> > >
> > >
> > >
> > >-------------------------------------------------------
> > >This SF.Net email is sponsored by: INetU
> > >Attention Web Developers & Consultants: Become An INetU Hosting Partne=
> r.
> > >Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commissio=
> n!
> > >INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> > >_______________________________________________
> > >Dev-cpp-users mailing list
> > >Dev...@li...
> > >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> > >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
> > _________________________________________________________________
> > On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnm=
> ob=3D
> ile
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: INetU
> > Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission=
> !
> > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
> > _________________________________________________________________
> > The new MSN 8: advanced junk mail protection and 2 months FREE*
> > http://join.msn.com/?page=3D3Dfeatures/junkmail
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: INetU
> > Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission=
> !
> > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
>
>
>
> -- __--__--
>
> Message: 4
> From: "Daniel Glenfield" <sp...@ho...>
> To: g_...@ho..., dev...@li...
> Subject: Re: [Dev-C++] Comment Delimiters
> Date: Mon, 23 Jun 2003 13:21:14 +0100
>
> #if 0
> cout << "This code will not be compiled, but I don't know if it needs to =
> be=20
> syntactically correct or not. Probably does" << endl;
> #endif
>
> Yes I know I've forgotten to #include the iostream header.
>
>
> >From: "Damien ." <g_...@ho...>
> >To: dev...@li...
> >Subject: Re: [Dev-C++] Comment Delimiters
> >Date: Mon, 23 Jun 2003 06:41:24 -0400
> >
> >Guys, How exactly does '#if 0' ...#endif work? I assumed that the=20
> >preprocessor would skip the statements until it reached the #endif. =20
> >However, when I tried to compile the code(with gcc 3.2.2) below , i get=
> a=20
> >"missing terminator character ' error" . It seems as though the code=20
> >inside of an #if 0...#endif statement must be C/C++ accurate. It is eas=
> y=20
> >fixed with a /*... */ .Care to elaborate....?
> >/* IfZero.c */
> >#include <stdio.h>
> >int main(void)
> >{
> >#if 0
> >This line should not be worried about. I'm quite sure it will *not* be =20
> >included.
> >#endif
> >printf("...");
> >return 0;
> >}
> >
> >----Original Message Follows----
> >From: "Daniel Glenfield" <sp...@ho...>
> >To: or...@vp..., dev...@li...
> >Subject: Re: [Dev-C++] Comment Delimiters
> >Date: Mon, 23 Jun 2003 09:16:30 +0100
> >
> >Agreed. #if 0 ..#endif is a great way of doing it.
> >
> >
> >>From: OROSZI Bal=E1zs <or...@vp...>
> >>To: dev...@li...
> >>Subject: Re: [Dev-C++] Comment Delimiters
> >>Date: Mon, 23 Jun 2003 10:01:54 +0200
> >>
> >>Andr=E9 Mac=E1rio Barros wrote:
> >>>Dear Users,
> >>>
> >>> Suppose you can=B4t use the /* and */ comment delimiters to put
> in=20
> >>>comments
> >>>an area of a code in C++.
> >>> If I use the // command, must I put them in each line of this piece
> of
> >>>code?
> >>> Is there another way?
> >>
> >>There is a quick way:
> >>
> >>#if 0
> >>...
> >>#endif
> >>
> >>Because "0" is "false", #if 0 can be considered like if (false){...},=20
> >>which will in fact, never execute. So all code, with or without comment=
> s,=20
> >>will not be parsed by the C preprocessor there.
> >>
> >>This approach is also better, because /* */ comments cannot be nested.
> >>
> >>--
> >>Greetings,
> >> Bal=E1zs
> >>
> >>
> >>
> >>-------------------------------------------------------
> >>This SF.Net email is sponsored by: INetU
> >>Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> >>Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission=
> !
> >>INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> >>_______________________________________________
> >>Dev-cpp-users mailing list
> >>Dev...@li...
> >>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
> >_________________________________________________________________
> >On the move? Get Hotmail on your mobile phone=20
> >http://www.msn.co.uk/msnmobile
> >
> >
> >
> >-------------------------------------------------------
> >This SF.Net email is sponsored by: INetU
> >Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> >Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> >INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
> >_________________________________________________________________
> >The new MSN 8: advanced junk mail protection and 2 months FREE*=20
> >http://join.msn.com/?page=3Dfeatures/junkmail
> >
> >
> >
> >-------------------------------------------------------
> >This SF.Net email is sponsored by: INetU
> >Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> >Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> >INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> _________________________________________________________________
> Find a cheaper internet access deal - choose one to suit you.=20
> http://www.msn.co.uk/internetaccess
>
>
>
> -- __--__--
>
> Message: 5
> From: "Daniel Glenfield" <sp...@ho...>
> To: MDo...@OL..., dev...@li...
> Subject: Re: [Dev-C++] WRITING TO SERIAL PORT
> Date: Mon, 23 Jun 2003 13:28:07 +0100
>
> I'm not entirely sure of the syntax but...
>
> In DOS (command prompt) you can do
> nmake DebugBuild > LPT1
>
> to send output of the DebugBuild "build" to the printer attached to LPT1.=
> =20
> I'm not sure about how you could tie this in with your project though...
>
>
> >From: Dondolo Mpho <MDo...@OL...>
> >To: dev...@li...
> >Subject: [Dev-C++] WRITING TO SERIAL PORT
> >Date: Mon, 23 Jun 2003 10:23:36 +0200
> >
> >Hi all,
> >
> >I have been playing around with streams and need the following help.
> >I am able to print my files to our network printer and also write them t=
> o
> >specific network drives.
> >How do I write a device in one of my ports...eg, serial port
> >consider this code as an example.
> >
> >
> >
> >ofstream create(" \\omcwca054\\HPLJ5000 <file://\\omcwca054\\HPLJ5000> "=
> )
> >cout<<"The following will be printed to on lazer jet printer";
> >create<<" Mpho Dondolo\n"
> > <<" 45 Durban Ridge\n"
> > <<"Tyger Valley\n";
> >create.close();
> >
> >I want to write to my matrix display board that is connected to my seria=
> l
> >port.
> >
> >NB!!!! Please do not flip if have not supplied sufficient info. ( last i=
> =20
> >did
> >that, some guy almost had a heart attack) I am still new at this game
> >
> >
>
> _________________________________________________________________
> Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile
>
>
>
> -- __--__--
>
> Message: 6
> Date: Mon, 23 Jun 2003 12:26:20 -0500
> From: Brian Ackermann <bri...@gm...>
> CC: dev...@li...
> Subject: Re: [Dev-C++] FREE download: a HOW-TO use wxWindows with Dev-C++
>
> This is a multi-part message in MIME format.
> --------------000300010007070605010009
> Content-Type: text/plain; charset=3Dus-ascii; format=3Dflowed
> Content-Transfer-Encoding: 7bit
>
> Well, here's the part that works...
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
> =3D=3D=3D=3D=3D=3D=3D
> bja3622@ANN /c/wx/samples/minimal
> $ make -f makefile.unx c++ -c `wx-config --cxxflags` -o minimal.o=20
> minimal.cpp
> c++ -o minimal minimal.o `wx-config --libs`
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
> =3D=3D=3D=3D=3D=3D=3D
> and my flags look like this ::
>
> bja3622@ANN /c/wx/samples/minimal
> $ wx-config --cxxflags
> -I/usr/local/lib/wx/include/mswd-2.5 -D__WXDEBUG__ -D__WXMSW__ -mthreads=20
> -fno-pcc-struct-return
>
> bja3622@ANN /c/wx/samples/minimal
> $ wx-config --libs
> -L/usr/local/lib -Wl,--subsystem,windows -mwindows -mthreads =20
> /usr/local/lib/libwxmsw250d.a -ltiff -lrpcrt4 -loleaut32 -lole32 -luuid=20
> -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -ladvapi32 -lwsock32
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D...
[truncated message content] |
|
From: <or...@vp...> - 2003-06-27 16:37:32
|
Per Westermark wrote: > It's the result of your mail program configured to sending MIME Quoted > Printable format. Please turn off before posting code. Some mail readers > really hates this format... Mail readers with low bandwidth also really hate if 3 lines of text is written as reply to a letter, and the WHOLE original letter (40 KB or more) is quoted. I received the same mail 3 times as quotations, that adds up to 120 KB. All the same letter. This way I want to ask people, to quote only that part of the letter, which they reply to. It is a very bad habit to quote the whole message again (it doesn't make sense anyway), and makes people's life with low bandwidth a hell. Thank you. -- Greetings, Balázs |
|
From: Per W. <pw...@ia...> - 2003-06-27 18:38:53
|
Whey I picked up the mail and answered, I never noticed the length of it. Because of the window height, the last line of text I saw was the lines 'God Bless', his signature and a couple of empty lines - I never even knew that there were a 40kB digest of miscellaneous earlier mails. /Per W On Fri, 27 Jun 2003, [ISO-8859-1] OROSZI Bal=E1zs wrote: > Per Westermark wrote: > > It's the result of your mail program configured to sending MIME Quoted > > Printable format. Please turn off before posting code. Some mail reader= s > > really hates this format... > > Mail readers with low bandwidth also really hate if 3 lines of text is > written as reply to a letter, and the WHOLE original letter (40 KB or > more) is quoted. I received the same mail 3 times as quotations, that > adds up to 120 KB. All the same letter. > > This way I want to ask people, to quote only that part of the letter, > which they reply to. It is a very bad habit to quote the whole message > again (it doesn't make sense anyway), and makes people's life with low > bandwidth a hell. > > Thank you. > -- > Greetings, > Bal=E1zs > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: INetU > Attention Web Developers & Consultants: Become An INetU Hosting Partner. > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |