0

ok Ihave developed some code that i am having trouble with how I would I call teh text in the last functions to come into it the part labled 10 and then finally how would I incorperate the 3 parts to work on the first part of the function. the parts labled What goes here???? are where I know Iwould make them call to a greater part to conjoin them together but how would I do that?

//****************************************************************************
    int getput()
    {
    string what goes here????;
    fstream streamObject("http://www.gutenberg.org/cache/epub/1342/pg1342.txt");
    fstream localFile("pap.txt");
    fstream newFile("new.txt");



        if(streamObject.fail())
            cout << "file failed to load." << endl;
        else
            cout << "file load was successful." << endl;

        if(localFile.fail())
            cout << "file2 failed to load." << endl;
        else
            cout << "file load was successful." << endl;

        while(!streamObject.eof())
        {
            streamObject.put(localFile.get());
        }

        streamObject.close();

        char single = localFile.get();
        while(!localFile.eof())
        {
            what goes here???? += single;
            single = localFile.get();

        }
        localFile << newFile;

        localFile.close();

        asciistring(what goes here????);
        doubledelete(what goes here????);
        numberwordsinstring(what goes here????);





        return 0;

    }
//****************************************************************************    
        int asciistring() { 

    char String[100]; 
    int Sum,Index; 
    Sum=0; //Sum is initially zero 

    printf("Enter the string:\n"); 
    gets(String); //Accept String from User 

    for(Index=0;Index<strlen(String);Index++) 
    { 
    Sum+=(String[Index]); //Adds (the ASCII values of) the String characters. 
    } 

    printf("The sum is %d\n",Sum); //Printing it as %d gives the equivalent ASCII value. 

    return 0; 

    }


//****************************************************************************    
     int doubledelete(){

        cout << forceSingleSpaces1("sentence1.  sentence2.  end.  ") << endl;

        return EXIT_SUCCESS;
    }
//****************************************************************************    
    int numberwordsinstring()
    {
        int i, numspaces;
        char nextChar;
        string msg;

        numspaces=1;

        cout << "Type in a string\n";
        getline(cin, msg);

        // checks each character in the string
        for (i=0; i<int(msg.length()); i++)
        {
            nextChar = msg.at(i); // gets a character
            if (isspace(msg[i]))
                numspaces++;
        }
        cout << "\nThere are " << numspaces << " words in this string.";
        cin.ignore();
        return 0;
    }
2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by thines01
0

You would give your string a name:

string strData = "this is neat";

When you call a function that needs to use a string, you would pass the name of the string.

DoSomething(strData);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.