Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- // Lab 19 stuff
- #include "stdafx.h"
- #include <string>
- #include <iostream>
- using namespace std;
- int parseInt(string q);
- void parse(string loadin, string &title, int &mns, int &scs, string &bname);
- int main()
- {
- string p;
- getline(cin, p);
- string t, b;
- int m, s;
- parse(p, t, m, s, b);
- return 0;
- }
- int parseInt(string q) {
- cout << q << endl;
- int val = 0;
- int placeval = 1;
- for (int i = 0; i < q.size(); i++) {
- val += (q[q.size() - i - 1] - '0')*placeval;
- placeval *= 10;
- }
- return val;
- }
- void parse(string loadin, string &title, int &mns, int &scs, string &bname) {
- cout << loadin.find_last_of('\"') << endl;
- title = loadin.substr(1, loadin.find_last_of('\"') - 1);
- mns = parseInt(loadin.substr(loadin.find_last_of('\"') +2, loadin.find_first_of(':')-loadin.find_last_of('\"')-2) );
- string pt2 = loadin.substr(loadin.find_first_of(':')+1, loadin.size() - loadin.find_first_of(':'));
- cout << pt2 << " " << mns << endl;
- scs = parseInt(pt2.substr(0, pt2.find_first_of(' ')));
- bname = pt2.substr(pt2.find_first_of(' '),pt2.size()-pt2.find_first_of(' '));
- //
- cout << title << " | " << mns << " " << scs << " | " << bname << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement