Need help on C++. What's the problem with this code:
```
#include
int main()
{
double var = "My Text";
std::cout
Need help on C++. What's the problem with this code:
```
#include
int main()
{
double var = "My Text";
std::cout
Try building a program that makes a request to the Python website and downloads 3.6
>My Text
That's not a double, that's a char*
Do your own homework faggot
okay first delete all your code then go learn what a type is.
fuck away
Should be "char const*" otherwise you're not guaranteeing you won't try to alter the string-pool
Only in C++. If you did that in C you'd be shot by your coworkers.
#include
#include
...
std::string var = "My Text";
...
>std::string var = "My Text";
try
auto var = "My Text"s;
#include
using namespace std
int main()
{
double var = "My Text";
std::cout
>trying to put a string into a double
lol what a tard
this is a bait thread right?
>using namespace
>std::cout
#using std;
int main(string[] args){
long unsigned double var[] = 'my text';
printf(var[])
Help me out real quick. First time using codeblocks and I keep getting "nan" as an answer.
The reason I say quick is because I am a little embarrassed this is fucking me up
Pic related
>Snapchat-
fuck right off, brainlet
try restarting codeblocks. You don't have an error, sometimes codeblocks fucks up like that.
Have you used it before? Is your compiler properly configured?
you're using those values before theyre defined. also they should be inside main or a function. global variables are generally bad style
wait nvm you put the equation before giving the variables values.
I can't believe i took the fucking bait
I think he's trolling, or it's a female
you have an int function
but you returned nothing
you used a double and then tried to put a string in it.
#include
int main()
{
std::string var = "My Text";
std::cout
The fuck you trying to put a string in a double for user? Use an auto or string type. C++ is explicit, unlike Python or JavaScript...
Your code smells Jerry.
>No return value
>'\n' is a single character not a string
>double for a char array? what the fuck was the thought process behind this?
just do
int main(int argc, char ** args)
{
const char * var = "My Text";
printf("%s\n", var); or just use:
puts(var);
return 0;
}
>I learned js in college and think every language is the same
Atleast read a basic standard before posting you fucking mong.
If you're going to print shit, you should do a cout
You mean "char const *" compiles in c++? Since when?
Kerk
I cannot tell whether this is bait or not. If it isn't then
The problem is you, you don't even know what data types are. Python or Scratch is probably best for you.
Yes, in C++
char const* x = "test";
works, but
char* x = "test";
gives a compile time warning.
But in C, you should never use type qualifiers except for restrict, and only in rare cases where it's necessary for optimization.
>actually replying this bait
Why would you use an unsafe char pointer in C++ vs the standard std::string?
>double var = "My Text";
A string is a triple
Why would you ever want to use a 328 byte data structure over an 8 byte data structure?
You included the standard namespace but still did `std::cout`. Lol.
You don't have to return a value.
Forgot to include the string library.
>printf
This is what happens when you only half listen to retarded Sup Forums memes.
When you're not in 1960 anymore.
is that java, c++, and python?
Completely irrelevant in 2017, especially over the convenience, built-in features, safety and compatibility (std::string::c_str()).