Solved C++ auto capitializing of variable?

Hewlett-packard / Pavilion touchsmart amd a...
February 18, 2014 at 14:48:52
Specs: Windows 7, 8GB
Here is my code, I want whatever the user inputs to be automatically capitilized then processed, but I can't figure out where or how to implement this, I've tried multiple ways and I can't figure it out, please help

#include <iostream>
#include <string>
#include <ctype.h>
#include <string.h>
#include <fstream>
using namespace std;
//general conversation
string pb[5] = {"HELLO","HI","HEY","WHAT IS YOUR NAME","WHO CREATED YOU"};
string rb[5] = {"Hi there","Hey","I am fine","My name is Ian","General language knowledge module created by Daniel Mombourquette"};

void init()
{
//to be later filled with things.
}

void respond(const string inp)
{
int n = sizeof(pb) / sizeof(string);
for(int i = 0; i < n; i++)
{
if(!pb[i].compare(inp))
{
cout << rb[i] << "\n";
}
}
}

int main()
{
label:
std::string name;
init();
int run = 1;
string inp;
std::getline (std::cin,inp);
respond(inp);
ofstream myfile;
myfile.open("log.txt", ios_base::out | ios_base::app);
myfile << inp << endl;
myfile.close();
goto label;
}



See More: C++ auto capitializing of variable?

Report •

#1
February 23, 2014 at 09:04:28
✔ Best Answer
As there has been limited replies on the topic you might look here

http://www.cplusplus.com/forum/begi...
http://www.cplusplus.com/reference/...

Regards,

::mike


Report •
Related Solutions


Ask Question