C++ :: Write Program That Scans Entered String For Keywords And Responds?
Nov 17, 2014
I'm attempting to write a program that will respond to me a lot like cleverbot or Siri. I can take care of making the program do the things I want it to do such as shutdown the computer, play a song, or whatever but I do not yet understand how to make it read strings I say, and make sense of them using certain words in that sentence. I could probably make an endless if statement to see if a string entered (using cin on a string[]) matches a certain other string, covering a million different sentences with a million different combos of words and spelling and capitalization but I want to enter a sentence and have the program search for keywords and then act on them. For example, with "shutdown" and "computer" being the keywords that make the program run the shutdown operation, so that whether I say "Yo, program, shutdown this computer for me!" or "Shutdown this computer", it will use the common terms here, "shutdown" and "computer" to know what to do.
This program will allow the user to input string then scans the file if it contains the same string given by the user. But i always get "MATCHED" even if i enter random string. I tried and tried to place the if statement in different positions but i dont get my expected output.
Code: #include<stdio.h>#include<stdlib.h> #include<time.h> #include<string.h> int main() { int found;
I have a problem with a program..I wanna make a program for scan the computer screen.I mean for example there is a video which shows just 5 pictures(apple,pear,banana,strawberry,cherry pictures) but this pictures are turning nonstop in one second. and this case is continuous progress.There are 5 pictures and are chancing. Lets get my problem, I wanna make a program and when apple on the screen my keyboard will push 1,when pear on the screen my keyboard will push 2,banana is 3,strawberry is 4,cherry is 5. I have this 5 pictures which are in the video and I will introduce tham to program and I wanna compare my lib. and screen and get output.
I am trying to write code to find all the prime numbers before a user entered number. I started with a working program and when I tried to create a function, it got all messed up.
Code:
#include <stdio.h> int is_prime( int num ); int get_positive_integer(void); int main( ) { int upper; /* upper limit to check */ int num; /* current number to check */ int isprime; /* used to flag if number is prime or not */
I am trying to write a program that determines if a string has all unique lowercase letters. However i am unable to understand how to write the code as i am very new to C++ and my professor has given us some tasks to do and has not taught us any C++. i am familiar with the syntax but am not able to understand the tasks properly and able to complete them successfully
#include <iostream> #include <cctype> using namespace std;
I'm trying to write a program that uses the Boost library to input a string date in the format mm/dd/year and outputs to the string its corresponding day of the week. I wrote the program that I thought would accomplish this, but it doesn't seem to work. Below is the code I wrote:
When I compile this using codeblocks it gives me the error "In function `ZN5boost9date_time19month_str_to_ushortINS_9gregorian10greg_monthEEEtRKSs':| C:Users osaDesktop est3........Liboost_1_55_0oostdate_timedate_parsing.hpp|67|undefined reference to `boost::gregorian::greg_month::get_month_map_ptr()'". And it takes me to the file date_parsing.hpp and highlights line 67. I don't understand why this isn't working.
I am beginner with C++ and I want to know. When do I use new and delete keywords? And what can I use them to do? Only thing I know about the new keyword and delete is that you can do this:
Code: int Size = 5; int *ptr = new int(Size); cout << *ptr << endl; delete ptr; And more . . .
But when do you use this keywords? I am just curios about them and want to now if them can be really effective to use.
A quick clarification on virtual methods after reading Jumping int C++ by Alex Allain. If a user wanted to extend a class from someone elses library and override its methods that do not contain virtual methods; how would one call the overridden class if it is referred to by its super type
in other words how would someone override a method from someone elses library that does not have virtual keywords.
212Untitled1.cpp[Error] stray '222' in program 212Untitled1.cpp[Error] stray '' in program 212Untitled1.cpp[Error] stray '222' in program 262Untitled1.cpp[Error] stray '222' in program 262Untitled1.cpp[Error] stray '' in program 262Untitled1.cpp[Error] stray '222' in program Untitled1.cppIn function 'int main()': 2125Untitled1.cpp[Error] 'n' was not declared in this scope
This is my program, for now it is intended to compute permutations of any string entered, but the function ox will not return the final x value. ox is the function that actually computes the permutations so the return of the x value is critical.
Code: #include<stdio.h> #include<string.h> int ox(int x); int main() { int x; char input[10];
Night now I'm working on part of a function that scans in two sets of coordinates. Is there a way I can scan both sets of coordinates in with the same scanf?
Code: printf("What are the first coordinates for destroyer: "); scanf_s("%d%d", &destroyer_1, &destroyer_2); gameboard[destroyer_1][destroyer_2] = 'd'; printf("What are the second coordinates for destroyer:
I am new to c++ programming, and I wrote this program. It runs perfectly but the problem is I want the program to stop If I entered letters other than A,B or C
The code as follows:
#include <cstdlib> #include <iostream> #include <cstring> #include <iomanip> using namespace std ; int main() { // Deceleration Statements
I'm trying to code a Singly-Linked List(Double Pointers) selection sort program and I can't tell what the problem is. My compiler says no errors but when I run the program, it crashes right after I enter the values.
I am trying to do a while loop that terminates the program when 99999 is entered but otherwise allows infinite integers to be entered. My problem is that when a negative number is entered it crashes and also when I enter a number it displays it twice.
#include <stdio.h> #include <stdlib.h> main() { int number; printf("Input an integer. "); do { scanf("%d",&number); /* read a single integer value in */ printf("%d ",number); } while (number != 99999); }
The program should find and delete all vowels in a word that is user entered. This is what I have so far and I know it should be essentially this format I just don't know how to set entered word and word equal to each other.
Code:
#include <string> #include <iostream> using namespace std; void vowelremover(string&); string word; int main () {//string word;
I need to have a program display an error message if the variable entered isn't an integer but then I want it to cin again. I have this but it doesn't work:
cout << "Enter an Integer: " ; for (;;) { cin >> var; if (!cin) {
[Code] ....
I am not sure how to do what I want and this doesn't work, it just repeats That wasn't an int.. over and over again.
My code is not moving past the line below...actually i am making a quiz and this piece of code id checking whether the entered answer is correct, from a file..
getline(anss,saveans); while(a<1) { getline(anss,saveans); if (saveans == ToString(randNum)) { getline(anss,saveans); if (saveans == ans)
I am trying to find the max number entered by the user, and it should terminate when a negative number is entered. For my code, it will just end when the user inputs a lower number than the previous. i.e.- 10 20 15 "The highest number is 20" when it should be "10 20 5 40 15 -1" "The highest number is 40". No arrays or do/while loops either.
#include <iostream> using namespace std; int Max(int x); int main() { int x;
I am having an issue with my sort function. This is one part of the Hash table program. The main issue is that I am trying to sort the pointer table after all of the values have been entered. The ptr_sort function is not a class function and so I am therefore unable to use the class variables psize and pTable. Is there another way I should be trying this? it is a Vector should I use the sort() function from the vector class in STL?
i have to write a function to modify the input string by substituting each alphabetical character. for example, 'Programming' to 'Rtqitcookpi' (mod_int = 2).
except when the string exceed 11 characters. I guess it's because it has to pick a fixed sized for the string? but what if I want to always be able to have string up to 200 character? because now I can't exceed 11..I know writing a string with c_str() works, but I would like to write/read the structure in one shot.