Hello everyone names Matt I'm new to the programming world, I have some assignments that im starting in my college class and would need some assistance getting them done.
I am using the Xcode for Mac so im also learning how everything is done. I had a bit of exercise on a pc and it seemed to be easier when debugging i was able to input examples into the black debugging screen I'm not sure if its called the command screen or not.
Here is my question that I'm working on
Write a program that opens a file and counts the whitespace-separated words in that file.?
My code that i wrote for this example is as follows...
#include <iostream>
using namespace std;
#include <iostream>
#include <string>
#include <fstream>
int main()
{
string filename = "Question 1.cpp"; // File name goes in here
ifstream file(filename);
int wordcount = 0;
string word;
while (file >> word)
++wordcount;
cout << "The file \"" << filename << "\" has " << wordcount << " words." << endl;
cin.get();
}
I was much used to using visual studio where i would compile and the window would ask for me to input a text or numbers etc... so then depending on my code it would execute the program based on my input parameters.
Can i run a window that prompts me in Xcode to input for example a string name and then it executes to count the word spaces
Never mind i seemed to understand now i just began using this today so i figured out how the debugger works. :) Gotta keep trying until u get something!!
Now my question is am i answering this question properly that is being asked of me for the assignment.?