Thread: [Dev-C++] searching characters in a string newbie
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Patel, N. M <Nil...@qu...> - 2005-01-07 16:42:30
|
This maybe a easy one. But I have a string containing '|'. I need to write a little code where it search for '|' and returns whatever string is between the first '|' and the 2nd '|'.=20 Myabe this might be more clear. cat|dog|mouse|house. the cat, dog, mouse and house and not predefined. so i need a way where i can search for '|' and another '|' and return dog.= =20 i tried doing a method using find_first_of method, but did not turn out = correctly.=20 any suggestions=3F -----Original Message----- =46rom: dev...@li... [mailto:dev...@li...]On Behalf Of dev...@li... Sent: Thursday, January 06, 2005 11:14 PM To: dev...@li... Subject: Dev-cpp-users digest, Vol 1 #2282 - 2 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. Priority Defualt (Rhys Owen) 2. Re: Priority Defualt (David McKen) --__--__-- Message: 1 =46rom: "Rhys Owen" <ska...@ho...> To: dev...@li... Date: Thu, 06 Jan 2005 17:53:23 +0000 Subject: [Dev-C++] Priority Defualt Hi, I want to know how to set the default priority of a C++ program to=20 realtime (in windows). If you know how to do this, or want me to be more specific, please reply. Cheers ~ Roo --__--__-- Message: 2 Date: Thu, 06 Jan 2005 20:57:11 -0500 =46rom: David McKen <dml...@co...> To: Dev-C++ Mailing List <dev...@li...> Subject: Re: [Dev-C++] Priority Defualt I assume you mean how to have the program set it's own priority to the=20 real time class. The following is a snippet from some code I wrote. # define WIN32_LEAN_AND_MEAN 1 # include <windows.h>* ... * if(SetPriorityClass( GetCurrentProcess(), IDLE_PRIORITY_CLASS) =3D=3D 0) { cout << "\nError setting priority for process id #" <<=20 GetCurrentProcessId() << endl; cout << "Error # =3D " << GetLastError() << endl; } Look for the documentation for the constant for the real-time class. If=20 you want the rest of the stuff in windows.h then you can remove the lean=20 and mean define. hys Owen wrote: > Hi, I want to know how to set the default priority of a C++ program to=20 > realtime (in windows). > If you know how to do this, or want me to be more specific, please reply. > > Cheers > ~ Roo > > > > > ------------------------------------------------------- > The SF.Net email is sponsored by: Beat the post-holiday blues > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > --__--__-- _______________________________________________ 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 End of Dev-cpp-users Digest =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=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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D The contents of this message, together with any attachments, are intended = only for the use of the person(s) to which they are addressed and may = contain confidential and/or privileged information. Further, any medical = information herein is confidential and protected by law. It is unlawful for= = unauthorized persons to use, review, copy, disclose, or disseminate = confidential medical information. If you are not the intended recipient, = immediately advise the sender and delete this message and any attachments. = Any distribution, or copying of this message, or any attachment, is = prohibited. =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=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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D |
|
From: <Rub...@al...> - 2005-01-10 15:56:50
|
Here is the code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc,char *argv[])
{
char *x,*y;
=20
if(argc=3D=3D1){
printf("Uso : 2token STRING\n");
return -1;
}
if((x=3D(char *)malloc(1000)) =3D=3D NULL)
return -1;
strcpy(x,argv[1]);
=20
if((y=3Dstrtok(x,"|")) !=3D NULL)
if((y=3Dstrtok(NULL,"|")) !=3D NULL)
printf("\n%s\n",y);
system("pause");
return 0;
}
Ruben Savia
Ingeniero Electr=F3nico
Datacom Services
eBD - eBusiness Division
Alcatel de Argentina S.A.
e-mail : rub...@al...=20
Phone: 5411 4349 - 1111 ext.1001
Fax: 5411 4349 - 1199
Alcanet : 2930-1001
Web site: www.ind.alcatel.com=20
|
|
From: Phil S. <ph...@st...> - 2005-01-07 20:07:41
|
On Fri, 7 Jan 2005 11:38:27 -0500, "Patel, Nilesh M" <Nil...@qu...> jotted some Wise Words of Wisdom: >whatever string is between the first '|' and the 2nd '|'.=20 strchr --=20 The latest survey displays that it requires an average of just 3.8 drinkings to effect a katzenjammer. But this tablets supports you elude hang-overs and wake up feeling immense from head to abdomen and everywhere else. |
|
From: <or...@vp...> - 2005-01-08 01:13:22
|
Patel, Nilesh M wrote: > This maybe a easy one. But I have a string containing '|'. > I need to write a little code where it search for '|' and returns > whatever string is between the first '|' and the 2nd '|'.=20 >=20 > Myabe this might be more clear. >=20 > cat|dog|mouse|house. >=20 > the cat, dog, mouse and house and not predefined. >=20 > so i need a way where i can search for '|' and another '|' and return d= og.=20 >=20 > i tried doing a method using find_first_of method, but did not turn out= correctly.=20 >=20 > any suggestions? Use string::find() to find both the first, and the second "|", then use=20 string::substr() to get what's in between. A very good reference about C++ strings can be found here: http://www.cppreference.com/cppstring.html -- Greetings, Bal=E1zs |