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.
View 1 Replies
ADVERTISEMENT
Sep 21, 2014
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;
[Code] ....
View 6 Replies
View Related
Nov 20, 2014
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.
View 3 Replies
View Related
Sep 30, 2014
I want this program by using only iostream.h & conio.h
View 4 Replies
View Related
Apr 9, 2014
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 */
[Code]...
It says the error is on line 23
View 6 Replies
View Related
Sep 16, 2014
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;
[Code].....
View 6 Replies
View Related
Apr 23, 2014
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:
#include <string>
#include <iostream>
#include "boost/date_time/gregorian/gregorian.hpp"
[Code]....
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.
View 3 Replies
View Related
Jul 25, 2013
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.
View 6 Replies
View Related
Mar 11, 2014
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.
ie
something.h
Code:
#include <iostream>
namespace game{
class character{
public:
std::string getName(){return "character";}
};
}
main.cpp
Code:
#include <iostream>
#include <vector>
#include "something.h"
using std::vector
class protagonist : game::character{
public:
virtual std::string getName(){return "protagonist";} };
[Code]...
View 5 Replies
View Related
Oct 3, 2013
/*
* echoString2.c
* Echoes a string entered by user. Converts input to C-style string.
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main(void) {
char aString[200];
char *stringPtr = aString;
[Code] ....
and these are my errors
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
View 3 Replies
View Related
Oct 15, 2014
The question I am given is this:
Given a line of words (total character number is less than 100,
start from odd position 1,
and end with newline char "
").
Write a program to reformat it that new output is formed by each char from its odd position first, then its even position char.
View 14 Replies
View Related
Feb 11, 2013
In my little experiment i am trying to get the compiler to recognize 1 word with 2 parts from a list of names.
For example: if the user wanted to choose "candy bar", from a list of items which include: "candy bar", "cat", "dog"
My current code can recognize words without a space like cat and dog. But how can i recognize candy bar?
I tried using getline but its of no use.
View 2 Replies
View Related
Jun 11, 2013
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];
[Code] .....
View 2 Replies
View Related
Nov 5, 2013
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?
ex. scanf("%d%d%d%d," &destroyer_1, &destroyer_2, &destroyer_3, &destroyer_4)
but that didn't work...
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:
[Code] .....
View 5 Replies
View Related
Apr 29, 2013
How can loop this function so it keeps asking the user till they enter a correct letter that can be found in the unscrambled array?
Code:
char LetterGuessed(char unscrambled[]) {
char c;
printf("+-----------------------------+
");
printf("| Please guess a letter: |
[Code] .....
View 1 Replies
View Related
Apr 15, 2014
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
[Code] ....
View 6 Replies
View Related
Mar 25, 2014
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.
Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef struct node{
int elem;
struct node* link;
[Code] ....
The compiler that I'm using is Dev-C++.
View 2 Replies
View Related
Oct 21, 2014
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);
}
View 14 Replies
View Related
Mar 25, 2013
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;
[Code]....
View 3 Replies
View Related
Nov 8, 2013
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.
View 8 Replies
View Related
Apr 15, 2014
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)
[Code] ....
View 9 Replies
View Related
Nov 11, 2013
How can i make my program to accept only numerical values and gives a error notice if a character or a symbol is entered???
View 4 Replies
View Related
Jul 15, 2014
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;
[Code] ....
View 9 Replies
View Related
Nov 19, 2013
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?
#include "/home/onyuksel/courses/340/progs/13f/p9/util9.h"
#include "/home/onyuksel/courses/340/progs/13f/p9/hTable.h"
#ifndef H_TABLE1
#define H_TABLE1
void ptr_sort ( );
[Code] ....
View 1 Replies
View Related
Oct 8, 2014
i have to write a function to modify the input string by substituting each alphabetical character. for example, 'Programming' to 'Rtqitcookpi' (mod_int = 2).
View 1 Replies
View Related
Jan 11, 2015
I have a structure :
struct Entrainement{
string muscleCible, nom, unitesObjectif;
double objectifActuel, dernierObjectif, objectifInitial, capaciteInitiale, progression[10];
};
and I want to write in a binary file the structure. The following works perfectly....
(*pointeurFichierEntrainementBin).write((char*)&exercice, sizeof(Entrainement));
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.
View 1 Replies
View Related