LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-23-2004, 11:20 PM   #1
tekmorph
Member
 
Registered: Aug 2004
Location: Ohio
Distribution: Mandrake 10.0
Posts: 68

Rep: Reputation: 15
text to ascii


Hello, I was hoping someone could point me in the right direction. I would like to create an application that converts strings of text into its ascii equal. If someone knows of a good tutorial that would be great.Thanks alot.
 
Old 10-24-2004, 12:07 AM   #2
xode
Member
 
Registered: Aug 2003
Distribution: Mandrake 9.0; FC4; FC8; SUSE 10.3; SUSE 12.1; SUSE 13.2
Posts: 638
Blog Entries: 1

Rep: Reputation: 52
Do you mean: replace each character in the text strings by its corresponding ASCII code? Could you be more specific.
 
Old 10-24-2004, 12:16 AM   #3
randyding
Member
 
Registered: May 2004
Posts: 552

Rep: Reputation: 31
hexdump -C yourfile.txt
 
Old 10-24-2004, 12:16 AM   #4
tekmorph
Member
 
Registered: Aug 2004
Location: Ohio
Distribution: Mandrake 10.0
Posts: 68

Original Poster
Rep: Reputation: 15
Yes I am sorry. Replace each charecter in a string with its corresponding ascii code. Its late and I have been up for awhile. I should have been more specific. I would like to be able to do this in c++ if possible. Thanks.
 
Old 10-24-2004, 12:18 AM   #5
tekmorph
Member
 
Registered: Aug 2004
Location: Ohio
Distribution: Mandrake 10.0
Posts: 68

Original Poster
Rep: Reputation: 15
randying, thanks man thats really cool.
 
Old 10-24-2004, 01:57 AM   #6
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Code:
#include <iostream>

using namespace std;

int main()
{
  char *msg = "This is a message";

  while(*msg)
  {
    cout << (int)*msg << endl;
    msg++;
  }

  return 0;
}

Last edited by itsme86; 10-24-2004 at 02:00 AM.
 
Old 10-24-2004, 02:49 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
There is a command already which will display the octal, hexadecimal, or decimal values of the characters in a file. It is the 'oc' command.
 
Old 10-24-2004, 07:50 AM   #8
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
I guess you mean 'od' (primarily: octal dump)
 
Old 10-24-2004, 09:57 AM   #9
tekmorph
Member
 
Registered: Aug 2004
Location: Ohio
Distribution: Mandrake 10.0
Posts: 68

Original Poster
Rep: Reputation: 15
Hey thanks everyone, they all will help me do what I need. itsme86 thanks for the code, again thanks everyone.
 
  


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
ASCII C Help, Please InvisibleSniper Programming 33 10-10-2005 10:25 AM
Convert ASCII text to an audio file ed_homeLinux Linux - Software 1 07-22-2005 12:30 PM
ASCII help My_World Linux - General 1 04-13-2003 12:17 PM
RH7.2 prints even ASCII text badly! MikHud Linux - General 0 03-01-2002 09:20 AM
Displaying a text file in ascii?? bauld Linux - General 4 11-21-2001 07:33 PM

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

All times are GMT -5. The time now is 11:10 AM.

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