I have a student's project for school, I'm mostly programming in PHP, so C++ is not a my strong side :) Please let me know, is it possible to change variable which I mention in cin string? Maybe my code below will be more understandable:
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
string A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, R, Q, S, T, U, V, W, X, Y, Z;
string instrukcja;
string krok[3];
int i = 0;
string MAKENULL()
{
return " ";
}
void WRITE(string x)
{
cout << x;
}
int main()
{
// get instruction Begin
char s[10];
scanf("%10[0-9a-zA-Z ]", s);
istringstream iss(s);
while(iss)
{
string sub;
iss >> sub;
krok[i] = sub;
i++;
}
// get instruction End
if (krok[0] == "MAKENULL")
{
"" Variable in krok[1] "" = MAKENULL();
}
if (krok[0] == "WRITE")
{
WRITE("" Variable in krok[1] "");
}
if (krok[0] == "OPPOSITE")
{
OPPOSITE("" Variable in krok[1] "", "" Variable in krok[2] "")
}
}
In code above I will do something like ADD A B, and A should became A => A+B (one string stick to the other). Main question is, can I point a variable to change in scanf?
OPPOSITE()?string A,B,...). You could use astd::map<std::string,std::string>where the key is thestringthat you get fromscanfand the value (i.e. the second string in the map) is the value that you want to modify