Page 1 of 2 12 LastLast
Results 1 to 25 of 38

Thread: source

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82

    Exclamation source

    , - , C++ , .
    !


    Code:
    #include <algorithm>
    #include <fstream>
    #include <iostream>
    
    
    using namespace std;
    
    int show_menu()
    {
    	cout << "1. Add a bug report\n"
    		<< "2. Show bugs with specified level\n"
    		<< "3. Show bugs within a time period\n"
    		<< "4. Delete list of bugs\n"
    		<< "5. Quit\n";
    int val;
    cin >> val;
    return val;
    }
    int BF;
    void do_bugs()
    {
    for (;;) { //loop 'forever'
    int icmd = show_menu();
    switch(icmd) {
    case 1: {
    	string data, descript;
    int id, level;
    cout << "give: level date" << endl;
    cin >> level >> data;
    cout << "give: description" << endl;
    getline(cin,descript);
    if (data == "*") { data = "today"; }
    int next_id();
    id = next_id();
    
    
    
    bool add_record(BF,id,level,data,descript);
    cout << "bug " << id << " added...\n";
    } break;
    
    case 2: {
    	int level;
    cout << "give minimum level\n";
    cin >> level;
    show_and_filter(BF,level,**,**);
    } break;
    
    case 3: {
    	string d1,d2;
    cout << "give lower and upper dates\n";
    cin >> d1 >> d2;
    show_and_filter(BF,0,d1,d2);
    } break;
    
    case 4: {
    	string ids;
    cout << "give IDs in ascending order\n";
    getline(cin,ids);
    copy_and_remove(BF,DF,ids);
    } break;
    
    case 5: {
    default: cout << "unrecognized command\n";
    }
    }
    }
    Last edited by rabut; 25th August 2008 at 08:22.

  2. #2
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    , , " "

    , [cde] ... [/cde] , .

  3. #3
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82
    Quote Originally Posted by Pesho View Post
    , , " "

    , [cde] ... [/cde] , .
    , , :


    w.c: In function void do_bugs():
    w.c:38: error: add_record was not declared in this scope
    w.c:46: error: expected primary-expression before , token
    w.c:46: error: expected primary-expression before ) token
    w.c:46: error: show_and_filter was not declared in this scope
    w.c:53: error: show_and_filter was not declared in this scope
    w.c:60: error: DF was not declared in this scope
    w.c:60: error: copy_and_remove was not declared in this scope
    w.c:67: error: expected `}' at end of input

  4. #4
    Registered User 's Avatar
    Join Date: Feb:2006
    Location:
    Posts: 653
    - add_record do_bugs .

    - add_record switch ...
    Last edited by ; 25th August 2008 at 11:35.

  5. #5
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82
    , ?

  6. #6
    Registered User 's Avatar
    Join Date: Feb:2006
    Location:
    Posts: 653
    add_record, show_and_filter, copy_and_remove . , .

  7. #7
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82

    , out_file_name
    out_file_name. , /usr.
    ,

    . " invalid operands of types char [5] and char [5] to binary operator+ "

    Code:
    #include <iostream>
    #include <vector>
    #include <string>
    #include <fstream>
    #include <cstdlib>
    
    using namespace std;
    
    
    
    
    char out_file_name[5],out_file_name3[5];
    
    int main()
    {
    	
    
    	string pass;
    	string flag = "l";
    	cout << "Enter Nickname: ";
    	cin >> out_file_name;
    	cout << "Enter password: ";
    	cin >> pass;
    	char dir[5] = "usr/";
    	out_file_name3 = out_file_name3 + dir;
    	ofstream out;
    	out.open(out_file_name3);
    	out << out_file_name << " " << pass << " " << flag << endl;
    return main();
    }

  8. #8
    Wall-e delian's Avatar
    Join Date: May:2003
    Location: ::1
    Posts: 4,723
    "+" strcat.
    , 5 , 10 - .

  9. #9
    ɐ-əpoɔᴉu⋂ ɐ ə anrieff's Avatar
    Join Date: Apr:2004
    Location: Sofia
    Posts: 8,448
    ... "return main();", , ...
    "return 0;"
    , . .
    "640K ught to be enough for anybody" - Bill Gates, 1981
    ::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel

  10. #10
    Wall-e delian's Avatar
    Join Date: May:2003
    Location: ::1
    Posts: 4,723
    ,

  11. #11
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    ... include- <string>, - , C-.

  12. #12
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82
    ,




    . , "request for member out_file_name in dir, which is of non-class type char [256]"



    Code:
    char out_file_name[256],out_file_name3[5];
    
    int main()
    {
    	
    
    	string pass;
    	string flag = "l";
    	cout << "Enter Nickname: ";
    	cin >> out_file_name;
    	cout << "Enter password: ";
    	cin >> pass;
    	char dir[256] = "usr/";;
    	strcat (dir,out_file_name);
    	ofstream out;
    	out.open(out_file_name3);
    	out << out_file_name << " " << pass << " " << flag << endl;
    return 0;
    }
    Last edited by rabut; 27th August 2008 at 18:27.

  13. #13
    philosophus duratea icaci's Avatar
    Join Date: Oct:2006
    Location: Aachen
    Posts: 2,698
    strcat(dir.out_file_name). .
    Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others

  14. #14
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82
    ..... "error: incompatible types in assignment of char* to char [256]"


    strcat(dir.out_file_name) !

  15. #15
    Pesho's Avatar
    Join Date: Nov:2001
    Location: Sofia
    Posts: 5,169
    Quote Originally Posted by rabut View Post
    ..... "error: incompatible types in assignment of char* to char [256]"

    edit ( ):

    cin cast- out_file_name (char*).
    Last edited by Pesho; 27th August 2008 at 18:42.

  16. #16
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82
    Quote Originally Posted by Pesho View Post
    . "char dir[256]" - . ( "usr/" ). strcpy()- , C std::string, .
    "" , "Hello World", , ( )

    -

  17. #17
    Registered User 's Avatar
    Join Date: Feb:2006
    Location:
    Posts: 653
    Quote Originally Posted by rabut View Post
    "" , "Hello World", , ( )

    -
    , , ( ), . " ", ..

    . .

    : , - - . ( -, - ), - ,

    ..

  18. #18
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82
    Quote Originally Posted by View Post
    , , ( ), . " ", ..

    . .

    : , - - . ( -, - ), - ,

    ..
    , , , ,

    .. .

  19. #19
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82
    , "/usr" "/profile" = , = l
    Last edited by rabut; 28th August 2008 at 17:41.

  20. #20
    Registered User 's Avatar
    Join Date: Feb:2006
    Location:
    Posts: 653
    Code:
    int _tmain(int argc, _TCHAR* argv[])
    {
    	string nick;
    	string pass;
    	string flag = "l";
    	
    	cout << "Enter Nickname: ";
    	cin >> nick;
    	
    	cout << "Enter password: ";
    	cin >> pass;
    	
    	//         std::string,        nick.
    	
    	ofstream write;
    	write.open(nick.c_str());
    	write << nick << " " << pass << " " << flag << endl;
    
    	return 0;
    }

  21. #21
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82
    Last edited by rabut; 28th August 2008 at 22:26.

  22. #22
    Wall-e delian's Avatar
    Join Date: May:2003
    Location: ::1
    Posts: 4,723
    , .

  23. #23
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82
    Quote Originally Posted by delian View Post
    , .
    , ... , . , .

  24. #24
    Registered User
    Join Date: May:2008
    Location: varna
    Posts: 82

    ..!
    , , ,


    . - .

    :

    Code:
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    char in_file_name[256];
    
    int id();
    int console();
    int creat();
    int main2();
    
    ifstream in;
    
    string nick,pass,val;
    string usr="/usr";
    
    
    
    int main()
    {
    
    	cout << "Type login to login in system or creat to creat user: ";
    	string tp;
    	cin >> tp;
    	if (tp == "login") { return id(); }
    	if (tp == "creat") { return main2(); }
    	if (tp != "login" && tp != "creat") { return main(); }
    }
    
    int main2()
    {
    
    
    	cout << "New Username: ";
    	cin >> nick;
    	cout << "Enter password: ";
    	cin >> pass;
    return creat();
    }
    
    int creat()
    {
    
    	ifstream in;
    	ofstream out;
    	out.open("prof.txt");
    	out << "usr/" << nick <<  endl;
    	out.close();
    
    
    	in.open("prof.txt");
    	in >> in_file_name;
    	in.close();
    
    
    	out.open(in_file_name);
    	out << nick << " " << pass <<  endl;
    	out.close();
    
    	system("rm prof.txt");
    return main();
    }
    
    int id()
    {
    
    cout << "Enter you'r Nickname: ";
    	cin >> nick;
    	cout << "Enter you'r password: ";
    	cin >> pass;
    
    	ofstream out;
    	out.open("prof.txt");
    	out << "usr/" << nick <<  endl;
    	out.close();
    
    
    	in.open("prof.txt");
    	in >> in_file_name;
    	in.close();
    
    
    
    	system("rm prof.txt");
    
    	
    		ifstream in;
    	in.open(in_file_name);
    	string n,p;
    	in >> n >> p;
    	if ( nick == n && pass == p) { return console(); }
    	cout << "Wrong Username or Password!\n";
    	return main();
    }
    
    
    
    
    
    
    int console()
    {
    	cout << nick << ":~$ ";
    	cin >> val;
    	if (val != "help" && val != "creat" && val != "exit" && val != "logout") { cout << " '" << val << "'  ,   'help'  !" << endl; }
    	if (val == "logout") { return main(); }
    	if (val == "exit") { cout << "Bye Bye " << nick << "! Good Luck! :)" << endl; return 0; }
    	if (val == "help" || val == "Help") {cout << "\n" << "Help Menu:\n\n" << "!!!         !!!\n\n" << "help -  .\n" << "creat -    .\n"  << "exit -   ." << endl;}
    
    	if (val == "clear") { system("clear"); }
    
    
    
    return console();
    }
    Last edited by rabut; 1st September 2008 at 22:59.

  25. #25
    Registered User
    Join Date: Sep:2006
    Location: sofia
    Posts: 5
    , -
    Code:
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    void id();
    void console(const string& nick, const string& pass);
    void creat(const string& nick, const string& pass);
    void main2();
    
    int main() {
    	for (;;) {
    		cout << "Type login to login in system or creat to creat user: ";
    		string tp;
    		getline(cin, tp);
    		if (tp == "login") {
    			id();
    		} else if (tp == "creat") {
    			main2();
    		} else if (tp == "exit") {
    			break;
    		}
    	}
    	return 0;
    }
    
    void main2() {
    	string nick, pass;
    	cout << "New Username: ";
    	getline(cin, nick);
    	cout << "Enter password: ";
    	getline(cin, pass);
    	creat(nick, pass);
    }
    
    void creat(const string& nick, const string& pass) {
    
    	string tmp = "usr/" + nick;
    	ofstream out;
    	out.open(tmp.c_str());
    	if (out.is_open()) {
    		out << nick << endl << pass << endl;
    		out.close();
    	} else {
    		cout << "Unable to open file " << tmp << endl;
    	}
    }
    
    void id() {
    	string nick, pass;
    	cout << "Enter you'r Nickname: ";
    	getline(cin, nick);
    	cout << "Enter you'r password: ";
    	getline(cin, pass);
    
    	string tmp = "usr/" + nick;
    
    	ifstream in;
    	in.open(tmp.c_str());
    	string n, p;
    	getline(in, n);
    	getline(in, p);
    	if (nick == n && pass == p) {
    		console(nick, pass);
    	}
    	cout << "Wrong Username or Password!\n";
    }
    
    void console(const string& nick, const string& pass) {
    	for (;;) {
    		cout << nick << ":~$ ";
    		string val;
    		getline(cin, val);
    		if (val == "logout") {
    			break;
    		} else if (val == "exit") {
    
    			cout << "Bye Bye " << nick << "! Good Luck! :)" << endl;
    			exit(0);
    		} else if (val == "help" || val == "Help") {
    			cout << endl << "Help Menu:\n\n"
    				"!!!         !!!\n\n"
    				"help -  .\n"
    				"creat -    .\n"
    				"exit -   ." << endl;
    		} else if (val == "clear") {
    			system("clear");
    		} else {
    			cout << " '" << val
    					<< "'  ,   'help'  !"
    					<< endl;
    
    		}
    	}
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |