how to make a chatbot in c language for beginners
If you wanna create a chatbot that can do any program on your computer just use the c program :
Copy the below code and save use extension .c. example, filename. c.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <conio.h>
char user_input[];
int main()
{
system("COLOR df");
system("cls");
char ch[15];
time_t t;
time(&t);
system("COLOR df");
printf("\t\t 'Welcome sir'\n");
printf("\t\t ***********\n");
printf("what is your name:");
scanf("%[^\n]s",&ch);
printf("\t'%s'Sir how are you?",ch);
scanf("%s",&ch);
if(strcmp(ch,"fine")== 0||strcmp(ch,"good")==0||strcmp(ch,"Fine")==0||strcmp(ch,"Good")==0 ||strcmp(ch,"FINE")==0 ||strcmp(ch,"GOOD")==0)
{
printf("\t\t'Very good sir'\n ||I am your personal bot to do your pc operations.||\n ");
}
else
{
printf("\t\t'Don't worry sir.' i'll do your works.\n");
printf("**I am your personal bot to do your simple operation task**\n");
}
printf("\tJust command me like (open ___)\n");
printf("\tWhat do u want to do sir!!:");
while(1)
{
gets(user_input);
if(strcmp(user_input,"exit")==0||strcmp(user_input,"Exit")==0 ||strcmp(user_input,"EXIT")==0 ||strcmp(user_input,"nothing")==0||strcmp(user_input,"Nothing")==0)
{
system("cls");
printf("\t\t\a*Ok sir good bye. Have a nice day*");
break;
}
else if(strcmp(user_input,"open notepad")==0) //*notepad
{
printf("\aOk sir, opening Notepad \n");
system("start notepad");
}
else if(strcmp(user_input,"open word")==0) //*microsoft word
{
printf("\aOk sir, opening microsoft word for you \n");
system(" start winword");
}
else if(strcmp(user_input,"open powerpoint")==0) //*power point
{
printf("\aOk sir, opening powerpoint \n");
system("start powerpnt");
}
else if(strcmp(user_input,"open codeblocks")==0) //codeblock
{
printf("\aOk sir, opening codeblocks\n");
system("start codeblocks.exe ");
}
else if(strcmp(user_input,"open cmd")==0) //*cmd
{
printf("\aOk sir, opening command page\n");
system("start cmd");
}
else if(strcmp(user_input,"open file")==0) //*file
{
printf("\aOk sir,opening file \n");
system("start explorer");
}
else if(strcmp(user_input,"show time")==0 ||strcmp(user_input,"open time")==0) //*time
{
printf("\aOk sir,opening date and time \n");
printf("\t\t%s",ctime(&t));
}
else if(strcmp(user_input,"open snippingtool")==0) //*screenshot
{
printf("\aOk sir,opening snipping tool\n");
system("start SnippingTool");
}
else if(strcmp(user_input,"open youtube")==0) //*youtube
{
printf("\aOk sir,opening youtube\n");
system("start http://youtube.com");
}
else if(strcmp(user_input,"open calculator")==0) //*calculator
{
printf("\aOk sir,opening calculator \n");
system("start calc1");
}
else if(strcmp(user_input,"open excel")==0) //*excel
{
printf("\aOk sir,opening microsoft excel \n");
system("start EXCEL");
}
else if(strcmp(user_input,"open facebook")==0) //*facebook
{
printf("\aOk sir,opening facebook \n");
system("start http://facebook.com");
}
else if(strcmp(user_input,"open gmail")==0) //*gmail
{
printf("\aOk sir,opening gmail\n");
system("start https://mail.google.com");
}
else if(strcmp(user_input,"open google")==0) //*google
{
printf("\aOk sir,opening google ");
system("start https://google.com");
}
else if(strcmp(user_input,"open music")==0) //*music
{
printf("\aOk sir,opening music \n");
system("start wmplayer");
}
else if(strcmp(user_input,"open video")==0) //*video
{
printf("\aOk sir,opening video ");
system("start wmplayer");
}
else if(strcmp(user_input,"open settings")==0) //*settings
{
printf("\aOk sir,opening settings \n");
system("start SystemSettings");
}
else if(strcmp(user_input,"shut down")==0)
{
printf("\aOk sir,shuting down your computer");
system("shutdown /s");
}
}
return 0;
}
after copy this file save it and run it in your computer .Output will be :
output:
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteNice work. i also like programming and work with home appliances for details,click here
ReplyDelete