C++ quote mark and "read" -
davve95 - 01.05.2016
I'm programming some C++.
And I came across a problem, I can't use the quote marks in a cout.
I don't remember how to do.
I tried with this:
http://www.cplusplus.com/forum/beginner/2355/
But on that way it just thought that I wanted to end the sentence in my cout.
Or what I should say. I might have used it wrong though.
And another question:
How can I let a user paste a text? (when the built program are running)
And then I let the program for example add a character infront
(of what was pasted) or so.
I want it to read the text in a .txt file or just paste it normally into the program I created.
Edit: Post the easiest ways as I'm not a expert at C++ yet.
Re: C++ quote mark and "read" -
]Kurence[ - 01.05.2016
You can paste into console by right clicking the top left corner and choosing Edit > Paste
Re: C++ quote mark and "read" -
davve95 - 01.05.2016
Thanks! But I meant more how I should handle the pasted data in C++.
Like:
You write something in the created program.
Like: (example) "Appels"
And when you wrote something
it adds:
"2 Appels"
It's pretty hard to explain, sorry.
Re: C++ quote mark and "read" -
iZN - 01.05.2016
I wouldn't mind helping you out, but I'm confused, what do you want to do
exactly? Start off by showing your escape sequence code and the issue you're facing.
Re: C++ quote mark and "read" -
davve95 - 02.05.2016
Thanks for your reply!
1. I want to put qoute marks in this line. I mean I want to be able to print qoute marks, so I can see it when the program is running. (In a regular sentence)
But I don't know how.
Код:
cout << "SetDynamicObjectMaterial(" << objID << raknare3 << " , " << ind << " , " << << texture << " , " << modeltex << ");" << endl;
2. I'm creating a program for creating multiable varibles for pawn.
And I need a function so the user can enter his line of code (in this case SetDynamicObjectMaterial)
Like this:
pawn Код:
SetDynamicObjectMaterial(MiniGr, 0, 16202, "des_cen", "sandgrnd128");
SetDynamicObjectMaterial(MiniGr2, 0, 16202, "des_cen", "sandgrnd128");
And it comes out like this in my program:
pawn Код:
ObjectGround1 = SetDynamicObjectMaterial(MiniGr, 0, 16202, "des_cen", "sandgrnd128");
ObjectGround2 = SetDynamicObjectMaterial(MiniGr2, 0, 16202, "des_cen", "sandgrnd128");
The program have added "ObjectGround1 = " and "ObjectGround2 = "
And now the user can just copy the code.
But I don't know how to do.
I mean handle the pasted code/text that the user pasted.
And write some text infront of it.
Re: C++ quote mark and "read" -
Spmn - 02.05.2016
1. Add \ in front of quote mark: (like in PAWN)
Код:
cout << "This is a quote mark \" printed in my console!";
2. Copy-pasting text in a console program (mainly on pre-Windows 10 systems) implies many steps and a lot of headaches. So why don't you simple create a program that reads data from a file and writes it into another file? This way you won't have to use WINAPI and your code will be compatible with any OS.
Код:
#include <cstdio>
#include <cstring>
int main()
{
FILE* fin = fopen("fin.txt", "r");
FILE* fout = fopen("fout.txt", "w");
char line[256];
while(fgets(line, sizeof(line), fin) != NULL)
{
fprintf(fout, "var = \"%s\"", line);
}
fclose(fin);
fclose(fout);
return 0;
}
Also notice I added backslashes in front of quote marks to make them literal (printable).
Re: C++ quote mark and "read" -
Vule. - 02.05.2016
Quote:
Originally Posted by davve95
Thanks for your reply!
1. I want to put qoute marks in this line. I mean I want to be able to print qoute marks, so I can see it when the program is running. (In a regular sentence)
But I don't know how.
Код:
cout << "SetDynamicObjectMaterial(" << objID << raknare3 << " , " << ind << " , " << << texture << " , " << modeltex << ");" << endl;
2. I'm creating a program for creating multiable varibles for pawn.
And I need a function so the user can enter his line of code (in this case SetDynamicObjectMaterial)
Like this:
pawn Код:
SetDynamicObjectMaterial(MiniGr, 0, 16202, "des_cen", "sandgrnd128"); SetDynamicObjectMaterial(MiniGr2, 0, 16202, "des_cen", "sandgrnd128");
And it comes out like this in my program:
pawn Код:
ObjectGround1 = SetDynamicObjectMaterial(MiniGr, 0, 16202, "des_cen", "sandgrnd128"); ObjectGround2 = SetDynamicObjectMaterial(MiniGr2, 0, 16202, "des_cen", "sandgrnd128");
The program have added "ObjectGround1 = " and "ObjectGround2 = "
And now the user can just copy the code.
But I don't know how to do.
I mean handle the pasted code/text that the user pasted.
And write some text infront of it.
|
First code:
Код:
cout << "\"SetDynamicObjectMaterial(\""<< objID << raknare3 << " , " << ind << " , " << texture << " , " << modeltex << "\");""" << endl;
Explain second code a bit more or just add me on steam (
http://steamcommunity.com/id/vule99/) and we'll do it in 2 mins lol
Re: C++ quote mark and "read" -
davve95 - 02.05.2016
Damn, that I can't exlain the second one.
I'll try to make a demonstration program maybe.
Or I'll try to exlain again even closer.
1. I open the C++ program that I created in C++
2. I write something like SetDynamicObjectMaterial(MiniGr, 0, 16202, "des_cen", "sandgrnd128"); Or anything.
3. The program will add a character in front of it
like: Ground = SetDynamicObjectMaterial(MiniGr, 0, 16202, "des_cen", "sandgrnd128");
The program now added "Ground ="
For me.
But the problem is that I don't know how to do it.
With other words: You can write anything and it will just say something in front of it like add a character in front of it.
But in this case I need to add to paste like 5 ones.
Re: C++ quote mark and "read" -
Private200 - 02.05.2016
Quote:
Originally Posted by davve95
Damn, that I can't exlain the second one.
I'll try to make a demonstration program maybe.
Or I'll try to exlain again even closer.
1. I open the C++ program that I created in C++
2. I write something like SetDynamicObjectMaterial(MiniGr, 0, 16202, "des_cen", "sandgrnd128"); Or anything.
3. The program will add a character in front of it
like: Ground = SetDynamicObjectMaterial(MiniGr, 0, 16202, "des_cen", "sandgrnd128");
The program now added "Ground ="
For me.
But the problem is that I don't know how to do it.
With other words: You can write anything and it will just say something in front of it like add a character in front of it.
But in this case I need to add to paste like 5 ones.
|
You need enumerators. Just go for C#, will be way easier to be done. Compare strings and add values to the integer until you want to stop. I'll try to work around with C++ and get something done for you. Let me check.
Re: C++ quote mark and "read" -
Spmn - 02.05.2016
Quote:
Originally Posted by davve95
Damn, that I can't exlain the second one.
I'll try to make a demonstration program maybe.
Or I'll try to exlain again even closer.
1. I open the C++ program that I created in C++
2. I write something like SetDynamicObjectMaterial(MiniGr, 0, 16202, "des_cen", "sandgrnd128"); Or anything.
3. The program will add a character in front of it
like: Ground = SetDynamicObjectMaterial(MiniGr, 0, 16202, "des_cen", "sandgrnd128");
The program now added "Ground ="
For me.
But the problem is that I don't know how to do it.
With other words: You can write anything and it will just say something in front of it like add a character in front of it.
But in this case I need to add to paste like 5 ones.
|
Well, the code I posted in my previous post does that thing, except that instead of writing in console you'll have to write in a file.
Код:
fprintf(fout, "var = \"%s\"", line);
// var represents the prefix you want to add to the string.
Re: C++ quote mark and "read" -
Private200 - 02.05.2016
Done this in C# even though I'm not sure if this is what you're asking for. However, if you want this, just give me a PM and I'll send it to you.
Re: C++ quote mark and "read" -
davve95 - 03.05.2016
Thanks alot guys!
Spmn thanks! I misundestood the script as first. But now I see that it's what I need!
Private200 @ Thanks alot! But I'll try to make my own for fun.
Re: C++ quote mark and "read" -
Private200 - 03.05.2016
Quote:
Originally Posted by davve95
Thanks alot guys!
Spmn thanks! I misundestood the script as first. But now I see that it's what I need!
Private200 @ Thanks alot! But I'll try to make my own for fun.
|
http://i.imgur.com/uO6hqDq.gif
Having fun is always the best choice, as making things by yourself, however, C++ will be way harder than C#.