LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-29-2008, 06:22 PM   #1
amitabhm
LQ Newbie
 
Registered: Mar 2006
Posts: 6

Rep: Reputation: 0
Remvoing control M character from string


I get some string from windows program, which are passed on to my C library running on Linux. This library parses this messege and shows the output in a web browser.
Now there are many control M characters coming with the string.
How do I write a C program or function (for the library), which will remove any control M character from the string before passing it for next operation.

Thanks in Advance,
Amitabh.
 
Old 05-29-2008, 07:22 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
dos2unix
--- rod
 
Old 05-29-2008, 08:29 PM   #3
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Just to add some choices... There is info here on using perl or sed to do this. You can also do it interactively in vim
 
Old 05-29-2008, 09:52 PM   #4
Dan04
Member
 
Registered: Jun 2006
Location: Texas
Distribution: Ubuntu
Posts: 207

Rep: Reputation: 37
I haven't tested this, but try:

Code:
void RemoveCR(char* pszWinStr)
{
   char* src;
   char* dest;

   for (src = dest = pszWinStr; *src; src++)
   {
      if (*src != '\r')
      {
         *dest = *src;
         dest++;
      }
   }

   *dest = 0;
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove last character from file/string linuxchump Programming 34 06-08-2009 04:01 AM
remove the 'd' character from the end of string powah Programming 6 11-08-2007 07:00 AM
Comparison between character and hexadecimal string.. vishalbutte Programming 2 03-05-2006 07:59 PM
Picking a character from a string randomly swatward Programming 2 08-14-2005 01:21 AM
Using sed to convert a string to a character? whansard Linux - General 2 01-10-2003 05:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration