Modcraft - The community dedicated to quality WoW modding!

Community => Random => Topic started by: Yolo33 on July 03, 2015, 10:20:39 pm

Title: [C++] Letters
Post by: Yolo33 on July 03, 2015, 10:20:39 pm
ww3
Title: Re: [C++] Letters
Post by: bizzlesnaff on July 04, 2015, 01:55:12 am
Quote from: "Yolo33"
Hi, does someone know a script for Autohotkey or could make me a program that auto capitalizes only the first letter of a sentence? I would really appreciate it.

A program? Most of the free editor do this...or..did I missed the topic ;)?
Title: Re: [C++] Letters
Post by: schlumpf on July 04, 2015, 02:15:02 am
Code: [Select]
std::string input;
bool new_sentence (true);
for (std::string::iterator it (input.begin()); it != input.end(); ++it)
{
  if (new_sentence && std::isalpha (*it))
  {
    *it = std::toupper (*it);
    new_sentence = false;
  }
  else if (*it == '.') // possibly more sentence separators
  {
    new_sentence = true;
  }
}

Untested, unclear definition of "new sentence", not entirely sure, but probably a acceptable start.
Title: Re: [C++] Letters
Post by: Krang Stonehoof on July 04, 2015, 02:52:24 am
If you're working in CodeBlocks you can do that:

Code: [Select]
#include <iostream>
#include <ctype.h>

using namespace std;

int main()
{
    char c[] = "your sentence.";
    c[0] = toupper(c[0]);
    cout << c;
    return 0;
}

That's what we are learning in my country in high school.
Title: Re: [C++] Letters
Post by: Yolo33 on July 04, 2015, 02:05:47 pm
be possible?