Hamumu Software Hamumu Software Hamumu Software
Name
Password Register
Latest Journal update: Oct 18, 2017

Go Back   Hamumu Forum > General > General Blabber

Reply
 
Thread Tools Display Modes
Old 11-18-2012, 06:54 PM   #1
Boneheads
King of the Boneheads
 
Boneheads's Avatar
 
Join Date: Apr 2009
Location: Utah, United States
Posts: 1,249
Default I need more C++ help; a translator?

So I want to know how to make something that lets the user type in a few to a hundred lines of stuff then press enter (probably use getline) And it translates it into something else. Like this:

=TRANSLATION PROGRAM=
Hello. Please enter in stuff:
{here goes a getline I guess, let's pretend the user hit enter and they typed in the following:
blah blah
whatever hooplah
burgers and fries
}

Thank you. The result is:

Woah. Woah.
The letter Five.
Fries and Burgers?

=TRANSLATION PROGRAM=

What it should be doing is translating:

"blah" to "Woah."
"whatever hooplah" to "The letter Five."
"burgers and fries" to "Fries and Burgers?"

In reality, I'd have like:

"<acl type='program'>" to "#include <iostream> \n"+"using namespace std;\n"
"<base>" to "int main ()\n"+"{\n"
"</base>" to "}\n"
"</acl>" to " " (yes, completely blank)

So is it possible? How would I do it? And I want the user to be able to copy the translated text.

If anyone's wondering, it's for an ACL to C++ translator.
__________________
Website
Boneheads is offline   Reply With Quote
Old 11-19-2012, 03:52 PM   #2
Julian
Is a ninja
 
Julian's Avatar
 
Join Date: Aug 2005
Location: http://www.nationstates.net/dordinal
Posts: 3,077
Send a message via MSN to Julian
Default Re: I need more C++ help; a translator?

Use strings and strcmp. Also, you should read from a file rather than read from stdin, since that'll be a lot easier than inputting straight to the program. Ideally, you should have a command line program like this:

acl2cpp -in infile.acl [-out outfile.cpp] [other options that might be applicable, such as pass to a compiler after)

If -out is omitted, it would display to stdout (the command prompt/console).
Julian is offline   Reply With Quote
Old 11-19-2012, 04:19 PM   #3
Boneheads
King of the Boneheads
 
Boneheads's Avatar
 
Join Date: Apr 2009
Location: Utah, United States
Posts: 1,249
Default Re: I need more C++ help; a translator?

Thanks, but how should I lay it out? Like what functions? I've never loaded / saved files, so I have no idea how to do it.
__________________
Website
Boneheads is offline   Reply With Quote
Old 11-19-2012, 04:25 PM   #4
Julian
Is a ninja
 
Julian's Avatar
 
Join Date: Aug 2005
Location: http://www.nationstates.net/dordinal
Posts: 3,077
Send a message via MSN to Julian
Default Re: I need more C++ help; a translator?

You can find some pretty good tutorials for file I/O in C++ through Google. I'm not very familiar with it, so I won't be of much help. For processing command line arguments though, you'll have to use the int argc and char **argv that are in int main(int argc, char **argv).
Julian is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Translator evil eye Total Mayhem 14 08-11-2006 03:26 AM


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.
Site Map
Copyright 2017, Hamumu Games Inc.