Click here to Skip to main content
15,918,742 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Terminating explorer.exe Pin
hxhl9515-Mar-09 13:40
hxhl9515-Mar-09 13:40 
AnswerRe: Terminating explorer.exe Pin
Kenny McKee15-Mar-09 17:54
Kenny McKee15-Mar-09 17:54 
GeneralRe: Terminating explorer.exe [modified] Pin
hxhl9516-Mar-09 8:47
hxhl9516-Mar-09 8:47 
GeneralRe: Terminating explorer.exe Pin
Kenny McKee16-Mar-09 9:40
Kenny McKee16-Mar-09 9:40 
AnswerRe: Terminating explorer.exe Pin
Hamid_RT15-Mar-09 19:43
Hamid_RT15-Mar-09 19:43 
GeneralRe: Terminating explorer.exe Pin
hxhl9516-Mar-09 8:37
hxhl9516-Mar-09 8:37 
Questionhow to split input string into 4 components Pin
nyc_68015-Mar-09 9:37
nyc_68015-Mar-09 9:37 
AnswerRe: how to split input string into 4 components Pin
Stuart Dootson15-Mar-09 10:56
professionalStuart Dootson15-Mar-09 10:56 
Happy using C++ and STL? Then this should do you:

#include <sstream>
#include <iostream>
#include <fstream>
#include <string>

int main(int argc, char** argv)
{
   std::ifstream f(argv[1]);
   
   while (f)
   {
      std::string firstName, lastName;
      int age1, age2;

      f >> firstName >> age1 >> lastName >> age2;
      if (!f) break;
      std::cout << firstName << std::endl;
      std::cout << lastName << std::endl;
      std::cout << age1 << std::endl;
      std::cout << age2 << std::endl;
   }
}


This does require that your file has the right format - if you need to check the format, then I'd use a regex library, like Boost.Regex or the TR1 library included in VS2008. If you use one of those, this code works:

#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <boost/regex.hpp>

int main(int argc, char** argv)
{
   std::ifstream f(argv[1]);
   
   while (f)
   {
      std::string line;
      
      std::getline(f, line);
      
      boost::regex sreLine("^(\\S+)\\s+(\\d+)\\s+(\\S+)\\s+(\\d+)\\s*$");
      boost::smatch match;

      if (boost::regex_match(line, match, sreLine))
      {
         std::cout << match[1] << ' ' << match[2] << ' '
                   << match[3] << ' ' << match[4] << std::endl;
      }
      else
      {
         std::cerr << "Line \"" << line << "\" doesn\'t match\n";
      }
   }
}


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

GeneralRe: how to split input string into 4 components Pin
nyc_68015-Mar-09 13:15
nyc_68015-Mar-09 13:15 
GeneralRe: how to split input string into 4 components Pin
Stuart Dootson15-Mar-09 14:12
professionalStuart Dootson15-Mar-09 14:12 
AnswerRe: how to split input string into 4 components Pin
Joe Woodbury15-Mar-09 17:27
professionalJoe Woodbury15-Mar-09 17:27 
QuestionCDialogBar on a CDialog Pin
hatemtaleb15-Mar-09 7:04
hatemtaleb15-Mar-09 7:04 
AnswerRe: CDialogBar on a CDialog Pin
hatemtaleb15-Mar-09 10:00
hatemtaleb15-Mar-09 10:00 
Questionsimple c++ questions Pin
Mohammadj15-Mar-09 6:02
Mohammadj15-Mar-09 6:02 
AnswerRe: simple c++ questions Pin
Iain Clarke, Warrior Programmer15-Mar-09 6:22
Iain Clarke, Warrior Programmer15-Mar-09 6:22 
QuestionRe: simple c++ questions Pin
Mohammadj15-Mar-09 7:19
Mohammadj15-Mar-09 7:19 
AnswerRe: simple c++ questions Pin
Iain Clarke, Warrior Programmer15-Mar-09 8:09
Iain Clarke, Warrior Programmer15-Mar-09 8:09 
AnswerRe: simple c++ questions Pin
CPallini15-Mar-09 8:13
mveCPallini15-Mar-09 8:13 
GeneralRe: simple c++ questions Pin
Mohammadj16-Mar-09 7:30
Mohammadj16-Mar-09 7:30 
QuestionRe: simple c++ questions Pin
CPallini16-Mar-09 8:43
mveCPallini16-Mar-09 8:43 
AnswerRe: simple c++ questions Pin
Mohammadj18-Mar-09 9:28
Mohammadj18-Mar-09 9:28 
GeneralRe: simple c++ questions Pin
CPallini18-Mar-09 13:15
mveCPallini18-Mar-09 13:15 
GeneralRe: simple c++ questions Pin
Mohammadj19-Mar-09 1:07
Mohammadj19-Mar-09 1:07 
QuestionRe: simple c++ questions Pin
CPallini19-Mar-09 3:45
mveCPallini19-Mar-09 3:45 
QuestionWeb page download without images Pin
sonu.saini.76@gmail.com15-Mar-09 4:19
sonu.saini.76@gmail.com15-Mar-09 4:19 

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.