473,398 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

remove carriage return in a string plz....

Hi,

I want to remove the carriage return from the string using c++.

please anybody tell me.

i am reading the string from another file.(each string is a single line);
Nov 23 '06 #1
4 15820
Banfa
9,065 Expert Mod 8TB
Is there any data following the carridge return you wish to keep?

If not then just search down the string and replace the carridge return (character '\r') with the termintor (character '\0')
Nov 23 '06 #2
hai,
i try to find the '\r'
int len=[$string.size()-1;
if($string] == '\r')
{
$string[$string.size()-1] == '\0';
}
but it is not working.
please help.
Nov 27 '06 #3
horace1
1,510 Expert 1GB
Hi,

I want to remove the carriage return from the string using c++.

please anybody tell me.

i am reading the string from another file.(each string is a single line);
you can use strchr() to search the string, e.g. to find '/n' in ch[]
Expand|Select|Wrap|Line Numbers
  1. char * ptr r=strchr(ch,'\n');
  2.  
ithis returns NULL if '\n' is not in the string otherwise a pointer to '\n' which you can replace with '\0'
Nov 27 '06 #4
HAi,

I i use this one i get a parse error
distant_repeat_new_Nov21.cpp: In function `int main(int, char**)':
distant_repeat_new_Nov21.cpp:1526: parse error before `=' token
how can i rectify this one?.

and i used the another coding,
std::string::iterator e(sequence.end() - 1);
std::string::iterator e1(sequence.end() - 2);
if(*e == 'M' and *e1 == '^'){
sequence.erase(e);sequence.erase(e1);}

i used this in redhat linux . it is working fine. but i have a doubt, if i change any operating system it will show error or not . please clarify this one.

thank you.
Nov 27 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Laura D | last post by:
How can I identify a carriage return in C++? \r, \f, \0, \n, \t does not work. I have also tried !isprint(ch), iscntrl(ch), isspace(ch), etc....with no luck! I even poked around in the MSDN and...
2
by: John Dalberg | last post by:
Hi What's the regex to remove the carriage return/line field from a string? These can occur multiple times in the string as in xxx\r\n\r\n. -- John Dalberg
1
by: Jason | last post by:
hi, all, after I read a string from a text file, which contains a hidden character (carriage return) some where in the string, how can I remove this hidden character, because when I populated it...
3
by: Dinsdale | last post by:
I have an xml file that is read into an object using serialization. One of the objects has a string field called delimeter that I want to contain a carriage return. Instead of trying to include the...
1
by: asturt | last post by:
I have a string with multiple carriage returns in it. I need to remove the second carriage return but leave all the rest. Anyone know of a function that will do this? I've come up with this: ...
2
by: Ellen | last post by:
Hi All - I have some data that I export from Access to a pipe-delimited text file. Unfortunately, the text file always has a carriage return symbol at the end. I need to export this file...
5
by: vflyer | last post by:
I there a quick routine that removes trailing newline chars and carriage return? vFlyer Labs http://www.vflyerlabs.com
4
by: coolguyraj | last post by:
Hi. I have form that has a text box. I want insert unformatted text into the database. Even if the user gives an carriage return or New line feed in the database it should be stored as on single...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.