ok so my code will output the message its suppose to if it doesnt receive any arguments and im 100% sure the problem is the if statement with the argv[1] because i always have problems with char type for some reason. :(

#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
using namespace std;

int main(int argc, char * argv[]){
    ofstream file;
    stringstream ss;
    string input;
    string in;
    int x=0;
    int y=0;
    if( argc!=2){
        if(argv[1]=="new"){
            cout<<"FILENAME: ";
            getline(cin,in);
            ss<<in;
            file.open(ss.str().c_str());
            for(x=0; x<1;){
                cout<<"COMMAND: ";
                getline(cin,input);
                if(input=="help" || input=="--h" || input=="?"){
                    cout<<"Help"<<endl<<"Write"<<endl<<"Save"<<endl<<"Exit"<<endl;
                }
                if(input=="Exit" || input=="exit"){
                    x=1;
                }
                if(input=="Write" || input=="write"){
                    for(y=0; y<1;){
                        cout<<"TEXT: ";
                        getline(cin,input);
                        if(input==":help" || input==":Help"){
                            cout<<":Help"<<endl<<":Done";
                        }
                        if(input==":done" || input==":Done"){
                            y=1;
                        }
                    }
                }
                if(input=="Save" ||input =="save"){
                    file.close();
                }
                if(input=="Exit" || input=="exit"){
                    x=1;
                }
            }
            cout<<"Thanks for using CLI NOTES :)";
            cin.get();
        }
    }
    cout<<"Usage: "<<argv[0]<<" new"';
    cin.get();
}

Edited 6 Years Ago by Anarionist: n/a

Wow i can't believe i made that mistake i told it to execute the code if argc wasn't 2
EDIT: never mind i still need help

Edited 6 Years Ago by Anarionist: n/a

err no i haven't i completely forgot about that function thanks heh wow ive been working with strings to long :)

oh wait but argv[] is defined as char * argv[] how would i pass a pointer to strcmp . The definiton of strcmp is

int strcmp ( const char * str1, const char * str2 );

if im not mistaken a pointer to a const pointer would result in memory disruption would it not?

Edited 6 Years Ago by Anarionist: n/a

sorry i don't understand the syntax i tried to use it but compiler spits like 10 messages out plus isn't it a template (reason for asking is i don't know much about templates or their syntax). :) thanks for the help though

This article has been dead for over six months. Start a new discussion instead.