Click here to Skip to main content
15,910,981 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Is there a power function for integers in VC 9.0? Pin
CPallini14-Feb-09 6:31
mveCPallini14-Feb-09 6:31 
AnswerRe: Is there a power function for integers in VC 9.0? Pin
Stuart Dootson14-Feb-09 6:32
professionalStuart Dootson14-Feb-09 6:32 
QuestionDoes the piece of code have flaws, and can it be improved? Pin
followait14-Feb-09 2:40
followait14-Feb-09 2:40 
AnswerRe: Does the piece of code have flaws, and can it be improved? Pin
Stuart Dootson14-Feb-09 6:27
professionalStuart Dootson14-Feb-09 6:27 
GeneralRe: Does the piece of code have flaws, and can it be improved? Pin
followait14-Feb-09 13:32
followait14-Feb-09 13:32 
GeneralRe: Does the piece of code have flaws, and can it be improved? Pin
Stuart Dootson14-Feb-09 13:53
professionalStuart Dootson14-Feb-09 13:53 
GeneralRe: Does the piece of code have flaws, and can it be improved? Pin
followait14-Feb-09 14:50
followait14-Feb-09 14:50 
GeneralRe: Does the piece of code have flaws, and can it be improved? Pin
Stuart Dootson14-Feb-09 22:57
professionalStuart Dootson14-Feb-09 22:57 
You could use the std::tr1::regex[^] class (that's in from VC2008, I believe). Probably not as simple as sscanf for your case (although I wasn't aware sscanf would parse pseudo-character classes like the [^:] - there's me learnt something new today!).

You're on the cusp of needing something more complex than scanf, for which I guess regex would be as easy as anything else.

Anywhere - here's a regex equivalent for your code (the smiley is a colon followed by an open bracket:

#include <regex>
#include <iostream>
#include <string>

int main(void)
{
   std::tr1::regex re("^([^:]*):" // get first part of string terminated by colon
                      "(\\d+)\\s+(\\d+)\\s+" // numbers and separating whitespace
                      "(\\S)\\s+(\\S)$"); // Characters and separating whitespace
   std::string s("PICK ANY TWO:10 2 F F");
   std::tr1::smatch matches;

   if (boost::regex_match(s, matches, re))
   {
      std::string name = matches[1];
      int m = atol(matches.str(2).c_str());
      int n = atol(matches.str(3).c_str());
      char c = matches.str(4)[0];
      char d = matches.str(5)[0];
   }
}


Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

QuestionHidden Directory Pin
john563213-Feb-09 22:32
john563213-Feb-09 22:32 
AnswerRe: Hidden Directory Pin
Nuri Ismail13-Feb-09 22:49
Nuri Ismail13-Feb-09 22:49 
Questionhow can i realize if the user is connected to the internet or not? Pin
Joseph Marzbani13-Feb-09 21:44
Joseph Marzbani13-Feb-09 21:44 
AnswerRe: how can i realize if the user is connected to the internet or not? Pin
Nuri Ismail13-Feb-09 22:59
Nuri Ismail13-Feb-09 22:59 
AnswerRe: how can i realize if the user is connected to the internet or not? Pin
David Crow14-Feb-09 2:55
David Crow14-Feb-09 2:55 
AnswerRe: how can i realize if the user is connected to the internet or not? Pin
«_Superman_»14-Feb-09 2:56
professional«_Superman_»14-Feb-09 2:56 
AnswerRe: how can i realize if the user is connected to the internet or not? Pin
Hamid_RT14-Feb-09 4:04
Hamid_RT14-Feb-09 4:04 
AnswerVery fast search algorithm Pin
_MATRIX_13-Feb-09 19:05
_MATRIX_13-Feb-09 19:05 
GeneralRe: Very fast search algorithm Pin
Hamid_RT13-Feb-09 19:55
Hamid_RT13-Feb-09 19:55 
GeneralRe: Very fast search algorithm Pin
Rajesh R Subramanian13-Feb-09 23:10
professionalRajesh R Subramanian13-Feb-09 23:10 
GeneralRe: Very fast search algorithm Pin
Gary R. Wheeler14-Feb-09 2:48
Gary R. Wheeler14-Feb-09 2:48 
GeneralRe: Very fast search algorithm Pin
CPallini14-Feb-09 6:34
mveCPallini14-Feb-09 6:34 
QuestionSending Email in a program Pin
BobInNJ13-Feb-09 14:34
BobInNJ13-Feb-09 14:34 
AnswerRe: Sending Email in a program Pin
Garth J Lancaster13-Feb-09 16:06
professionalGarth J Lancaster13-Feb-09 16:06 
QuestionSoftware Activation Pin
DanYELL13-Feb-09 4:59
DanYELL13-Feb-09 4:59 
QuestionRe: Software Activation Pin
David Crow13-Feb-09 5:42
David Crow13-Feb-09 5:42 
AnswerRe: Software Activation Pin
DanYELL13-Feb-09 5:52
DanYELL13-Feb-09 5:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.