Quick summary for already programmer

Hello Friend

I am a programmer. I started to practice with c++ coding. I know php, javascript and mql4 languages. This languages are c++ based languages. I'm not far c++'s syntax or datatypes, structs or classes. also mql4 is %90 c++ based language so i know datatypes variables When i read i can read everything. also I can code c++. I know c++ language but i am little bit confused. If you help me i would be happy.

1- I use notepad++ for c++ programming. I use this compile command. I am not sure i am correct. It gives me error sometimes. I doubted that this is correct compile command.

C:\TDM-GCC-64\bin\g++.exe -g "$(FILE_NAME)"
cmd /c g++ -utf-8 -Wall -fpermissive -W -Wunused -std=c++11 $(FILE_NAME) -o $(NAME_PART).exe & IF ERRORLEVEL 1 (echo. && echo Syntax errors were found during compiling.) ELSE ($(NAME_PART).exe)


2- what is correct type of utf8 string datatype and how can i use it ? I tried char, string, TCHAR, wchar and wchar_t this data types does not support this characters "ş ç ğ ü ö" also i tried setlocale() function for set utf8 charset but it did not work. or i could not do it. what is correct data type is used for it. also i saw different coding style and example is someone uses int main() someone uses int _tmain(); also some people does not use int char float. they use different datatypes. what is correct datatype choosing

3- how will i create variable with string value ? I read on forum someone said that we can use newVar( Type, Name, Value); but it gives me error.

string new_var_name = "englishkey";

i would like to create variable with englishkey name like this

string englishkey = "";

How can i do ?

4- http://prntscr.com/gajzu3

this is my source code. I try to transfer data over some dll files write_to_ram() function writes data to variable that i choosed. I created output0, output1, output2, output3, output4. Primitive method but i could bot find any different solutions. my first idea was creating variable with my text key. i could not do it. is it possible ? then i created different variables for using. I am not sure it is stable or not. because when i use char datatype, datas are lost. Datas are not lost. as you can see in picture. I write to ram "Hello World ş ç i ğ" but program returns different output.

5- how can i compile this code as a dll.

If i solve this complexity, i can starting coding with c++. I just need a little guidance








I tried it. I still cant use turkish characters. Can you fix my code . I understand faster ? Because it looks difficult trust me i read on internet and tried a lot of thing i am programmer but i still could not do it. should i use spesific command for compile ?

I would like to write to output0 variable with write_to_ram("variablename","variable value"); and i would like to read variable data with read_from_ram("variablename") function. read_from_ram will return string and i will use this data. this program will be dll . i will transfer data between 2 different program with this dll. I try to do memory mapping.

please someone help me to learn how to start coding c++.

my compile command :

1
2
3
4
NPP_SAVE
CD $(CURRENT_DIRECTORY)
C:\TDM-GCC-64\bin\g++.exe -g "$(FILE_NAME)"
cmd /c g++ -utf-8 -g -Wwrite-strings -Wall -fpermissive -W -Wunused -std=c++11  $(FILE_NAME) -o $(NAME_PART).exe & IF ERRORLEVEL 1 (echo. && echo Syntax errors were found during compiling.) ELSE ($(NAME_PART).exe)




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <conio.h>
#include <locale.h> 
#include <string>
#include <stdio.h>
#include <unistd.h>

using namespace std;

char output0[1000];
char output1[1000];
char output2[1000];
char output3[1000];

int write_to_ram(int,char);

int write_to_ram(int degisken, char* veri) {
	int ret;
	if(degisken==0) {
		memcpy ( &output0, veri, 100 );
		ret = degisken;
	}
	return ret;
}
string read_from_ram(int);
string read_from_ram(int degisken) {
	string output = "";
	if(degisken==0) {
		memcpy ( &output, &output0, sizeof(output0)*2 );
		return output;
	} else if (degisken == 1) {
		memcpy ( &output, &output1, sizeof(output1)*2 );
		return output;
	}
	return "";
}
int main ()
{
  setlocale(LC_ALL, "Turkish"); 
  for(int r=0;r<7;r++) {
  char we[] = "Turkce karakter ş ç i ğ ü";
  int rp = write_to_ram(0,we);
  cout << "rp= " << rp << " rp *p = " << rp << " rp &p = " << &rp << endl;
  cout << " output0 = " << output0 << " output0 *p " << *output0  << " output0 &p " << &output0  << endl;
  sleep(1);
  }
  system("pause");
  return 0;
}

setlocale(LC_ALL, "Turkish");
This looks very suspious. "Turkish" doesn't seem to be valid name for the locale.
Locale names look like this: https://msdn.microsoft.com/en-us/library/39cwe7zf.aspx

To be certain check and see what setlocale returns.

EDIT

Just saw this post. https://www.quora.com/How-do-I-print-Turkish-characters-in-C++
Last edited on
Thomas1965 i tried examples on your link . it did not work.

http://prntscr.com/gbmmj8

http://prntscr.com/gbmmys

also i tried other ideas i found on internet. no one works

http://prntscr.com/gbmon4

http://prntscr.com/gbmpt0

http://prntscr.com/gbmrqr

no example is working. is not there nobody in this forum who is professional and can help and solve this problem ?

I tried a lot of thing and i cant do it. how cant i use turkish character in console and why is this difficult ? i really dont understand
In what encoding did you save your source code? Most compilers just binary copy the content of the strings in your source file into the output executable. Try saving your source file as UTF-8, set the locale to UTF-8 then try running your code.

Another factor to take into account is the terminal/console you're writing to. Most of the solutions you posted using _setmode are for the windows native console (not the console in notepad++ you seem to be using). Try running your program from the command prompt and see if that helps.

Printing UTF-8 to the console on windows is a bit of a problem though. Perhaps the most reliable way to output the characters is to convert them to whatever the local code page of your machine is, then writing that to the console. This can be accomplished by first converting the UTF-8 encoded string to a wide string using MultiByteToWideChar, then converting it back with WideCharToMultiByte, then writing the result of that to the console.

Also note that C++ does not have any string types that represent a given encoding. You have a std::string (which is internally an array of char), which just stores raw bytes. And you have an std::wstring (which is internally an array of wchar_t), which stores wide characters. What the bits in these strings represent is up to the encoding used to view them, and this can differ per platform and even per terminal.
Last edited on
Topic archived. No new replies allowed.