This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [C++] Letters  (Read 1384 times)

Yolo33

  • Registred Member
  • GM Isle Explorer
  • *****
  • Posts: 21
    • View Profile
[C++] Letters
« on: July 03, 2015, 10:20:39 pm »
ww3
« Last Edit: July 05, 2015, 01:25:08 pm by Admin »

bizzlesnaff

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 124
    • View Profile
Re: [C++] Letters
« Reply #1 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 ;)?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [C++] Letters
« Reply #2 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.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Krang Stonehoof

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 164
    • View Profile
Re: [C++] Letters
« Reply #3 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.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Yolo33

  • Registred Member
  • GM Isle Explorer
  • *****
  • Posts: 21
    • View Profile
Re: [C++] Letters
« Reply #4 on: July 04, 2015, 02:05:47 pm »
be possible?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »