Help ! please

Hello
i'm working on a project in c++ that convert a text to a language that i want and display the result example : " string x; if (x= "a") { printf("%");}"
Thanks :) please help me ...
Last edited on
Bump
What is your problem exactly? I assume what you wrote above is just pseudo-code. Also, the string comparison would be if(x=="a"), and printf would also need the argument list for what you want to sub in for your %? statements.
discofire thanks for your help , i want make a pg that convert any word i want to a code that i made it "Hello ---> 1bcae" reply please
There are a lot of ways to do that. Do you have a specific problem you are running into? Do you have any code?
I need a Simple code. my code won't work
can you elaborate ? i dont know in your example what exactly youre going to print out
actually i wrote it in vb.net anyway
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
if textbox1.text = "a" then
textbox2.text = "2"

else textbox1.text = "b" then
textbox2.text = "3"
....the same code.....
end if
End Sub
I'm just 15 yo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>

int main()
{
    const std::string hello = "hello" ;
    const std::string merhaba = "merhaba" ;

    std::string word ;
    std::cin >> word ; // read word from std input

    // translate and write to std output
    if( word == hello ) std::cout << merhaba << '\n' ; // hello => merhaba

    // else std::cout << word << '\n' ; 
}
Are you looking to make this a graphical application, or something that runs on a command line? Graphical might be a bit more involved, and you will almost certainly need to use a visual editor.

In C++, text can be handled in a few ways. The most common, and easiest to deal with these days is the string class.

http://www.cplusplus.com/reference/string/string/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>

using namespace std;
string myString;

int main() {
  cout << "Enter a string: ";
  cin >> myString;
  if(myString == "Hello") {
    cout << "1bcae" << endl;
  }
  //... put more if/else statements here as needed

  return 0;
}



That will run a very simple program reading in a string of text from the user, checking it against the word "Hello", then if it matches, it will print the string "1bcae".

You can add more of those if checks down the list, but the program will not break apart the string. If a user enters a sentence for instance, it will check the entire sentence against a word. If you want it to break the sentence apart into each word, and check each of them, the program will get a bit more involved. You will then need to find the break points in your string (spaces, tabs...) and use the substr function to extract the "words" one at a time from the sentence, then compare those to your list of converted words in a loop (most likely a while loop).
Topic archived. No new replies allowed.