Alireza
😭🥲
klimi
but like... if you google you should be able to get some responses https://stackoverflow.com/questions/6291458/how-to-convert-a-tchar-array-to-stdstring
Bhaskarjyoti
i m beginner at c programming
Bhaskarjyoti
PS C:\c tutorials> g++ main.c
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
Bhaskarjyoti
wht does it mean?
Bhaskarjyoti
plzz anyone help me
klimi
klimi
#paste
Bhaskarjyoti
#include<stdio.h>
int main()
{
printf("Hello world");
return 0;
}
klimi
then your toolchain is probably wrongly configured
klimi
how have you configured it?
Bhaskarjyoti
no
klimi
you haven't set up your toolchain?
Bhaskarjyoti
how to configured etc etc
Bhaskarjyoti
i start learning from youtube.. and i download visual studio as IDE and compiler as MinGw
klimi
visual studio doesn't come with MSVC? so you cannot compile within visual studio and that's why you use terminal?
Bhaskarjyoti
ok
Richard Luo 🐱
klimi
ok
what do you mean by "ok"? ... that was a normal question
Bhaskarjyoti
youtuber recommended to download Mingw as compiler
Bhaskarjyoti
i just started learning c programming yesterday .. so i dont know so much
Bhaskarjyoti
i will tell yu step by step .. plz help me
Bhaskarjyoti
step 1-i download visual studio
Bhaskarjyoti
step2-I download Mingw and add to path in MY PC
Bhaskarjyoti
i started writing my 1st command .. its showed error
Bhaskarjyoti
thats it
klimi
hm...
Bhaskarjyoti
code -#include<stdio.h>
int main()
{
printf("Hello world");
return 0;
}
klimi
and you are 100% sure that the data has been written to the disk and is not just in visual studio right?
Bhaskarjyoti
error-
PS C:\c tutorials> g++ main.c
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
PS C:\c tutorials>
Bhaskarjyoti
yes
Bhaskarjyoti
1 sec
Bhaskarjyoti
msvc is better than mingw
Bhaskarjyoti
?
Anonymous
Bhaskarjyoti
how to solved it?
Anonymous
how to solved it?
Create a new project and choose console application as project type
klimi
klimi
if you do gcc instead of g++ is there any change?
Anonymous
afaik his file is just the main.c
Yes but the main.o is linked with the runtime library. If the project settings says it is a Windows application, then the start up code in the run time library will call WinMain function and not main. Since there is no WinMain in his code, the linker is complaining about it
klimi
Bhaskarjyoti
PS C:\c tutorials> gcc main.c
/mingw/lib/libmingw32.a(setargv.o):(.text+0x33): undefined reference to `__chkstk_ms'
/mingw/lib/libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
Bhaskarjyoti
same error
klimi
klimi
how does your path looks
Bhaskarjyoti
yes
klimi
How does your path looks?
Anonymous
https://stackoverflow.com/questions/18649173/how-to-solve-undefined-reference-to-chkstk-ms-on-mingw
Bhaskarjyoti
C:\MinGW\bin
Anonymous
Bhaskarjyoti
yeah its my whole path
klimi
damn i dont know windows but shouldn't there be more things just one directory? /o\
Anonymous
Bhaskarjyoti
lets try
Bhaskarjyoti
if its works then fine
Bhaskarjyoti
and thanks for giving time for my problem
Kriss
is this not working cause I am trying to assign an int type to an address?**int main(){
int a =0 ;
int b =1;
int *ptr=&a;
std::cout<<"Initial Value: "<<*ptr <<"\n";
*ptr=&b;
std::cout<<"Changed Value: "<<*ptr<<"\n";
}**
Kriss
Ok got it , Thanks
\Device\NUL
Alireza
how can i convert TCHAR to string?
Alireza
I google it but I did not understand
Alireza
https://stackoverflow.com/questions/6291458/how-to-convert-a-tchar-array-to-stdstring
std::string BinRes::getAppLocation()
{
TCHAR szPathName[128];
std::string strPath;
GetModuleFileName(NULL, szPathName, 128);
strPath = szPathName;
int slashPos = strPath.rfind('\\');
if(slashPos == strPath.npos)
throw "Unable to get exe location";
strPath = strPath.substr(0, slashPos);
return strPath;
}
strPath = szPathName; in this line I have this error:
Error (active) E0349 no operator "=" matches these operands
what should I do ? I am not familiar with winbase syntax:(
Alireza
my problem is this👆 and I thought maybe I can convert TCHAR to string
Lxjxjxhks
#include<iostream>
using namespace std;
int main(){
char b;
string t= "hollder";
string a = "Amish";
int x = a.length();
for(int i = 0 ;i < x;i++){
if(t.find(a[i])){
cout << a[i]<< endl;
}
}
return 0;
}
Lxjxjxhks
I Want to print all nos in string a which are in string string t, that is "h" but its not working how I intended it to, its doing quite the opposite its prinnting A m i s in different lines without h
mito
mito
In your case t.find(a[i]) you're just finding the position of each and every letters in string a.
So when the i = 0 in loop, a[i] = a[0] = "h", but since "h" is at 0th position in string t, t.find(a[0]) returns 0 as expected, 0 means false, so the if condition won't happen for "h", but will happen for every other characters because anything other than 0 is true.
Nomid Íkorni-Sciurus
but because every S* system/environment/program is different
Map
Please,anyone knows good Android apk to learn c++
Semiu
Map
Anonymous
I want use qt to generate a static linked exe file
Anonymous
but i need to compile qt with configing by myself ,
Anonymous
where to download a ready-made qt
Anonymous
Hlo
Anonymous
I want to start c++ from the beginning
Anonymous
So plz can anyone help me