can i get some help?

see. i am making my own "siri" type of thing, its really simple, if i type in open weather, a link to a weather site opens, but when i type in open weather, the website dosent open, so i made a else statement to see if the program is bugging or not working, as it turns out its not working, what am i doing wrong?

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
#include <iostream>

#include <Windows.h>

#include <string>

using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */






int main() 
{
	//----------------------------------------------------------CMDS
	int cmd = 0;
	//----------------------------------------------------------URLs
	string weather = "https://www.weather.com/"; //url
	//----------------------------------------------------------inputs
	char input[32];
	
	cout << "Hi i am your new and own assistent, my name is alex\n";
	
	Sleep (2000);
	
	cout << "i am pritty new, so youll have to write in commands for now\n";
	
	cin >> input ;
	
	
if (input == "open weather"){
	ShellExecute(NULL, "open", weather.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
else {
	cout << "fail\n";
}
	return 0;
}
char input[32];
Use string. Not an array of char.
so if i do a string instead, will it work?
so this is what i did, but it still dosent work though
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
#include <iostream>

#include <Windows.h>

#include <string>

using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */






int main() 
{
	//----------------------------------------------------------CMDS
	int cmd = 0;
	//----------------------------------------------------------URLs
	string weather = "https://www.weather.com/"; //url
	//----------------------------------------------------------inputs
	string input;
	
	cout << "Hi i am your new and own assistent, my name is alex\n";
	
	Sleep (2000);
	
	cout << "i am pritty new, so youll have to write in commands for now\n";
	
	cin >> input ;
	
	
if (input == "open weather"){
	ShellExecute(NULL, "open", weather.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
else {
	cout << "fail\n";
}
	return 0;
}
Put this in line 32:
cout << "You entered: " << input << '\n';

Then read this:
https://stackoverflow.com/questions/5838711/stdcin-input-with-spaces
dude, thanks alot, i sat like 2 hours trying to figure it out!
i did remove stuff i dident need anymore, but heres how it is now
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
#include <iostream>

#include <Windows.h>

#include <string>

using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */






int main() 
{
	//----------------------------------------------------------CMDS
	int cmd = 0;
	//----------------------------------------------------------URLs
	string weather = "https://www.weather.com/"; //url
	//----------------------------------------------------------inputs
	string input;
	
	cout << "Hi i am your new and own assistent, my name is alex\n";
	
	Sleep (2000);
	
	cout << "i am pritty new, so youll have to write in commands for now\n";
	
	getline(cin, input);
	
if (input == "open weather"){
	ShellExecute(NULL, "open", weather.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
	return 0;
}
Repeater(1275)
1 more thing, how can i make it so it loops forever when you type in what it wants alex(the program) to do?
Last edited on
1
2
3
4
while(true)
{
  // forever loop
}
thanks alot, i was sceptical if forums would work, but now i have no doubt at all!
Topic archived. No new replies allowed.