Errors in Code(C++)

I am in no ways asking to do my homework. I've run into an error and I need clear instructions on how to fix it. Randomtext.cpp is the file that I saved from the teacher. Apparently it's over used? I don't know what should be named randomtext and what can be named something else.
Here's what the homework says.
" The attached file contains a long list of random numbers (Random.txt).
1. Copy the file to your hard drive.
2. Then write a program that asks user to enter the file name to open and validates that the file is successfully open.
3. Once the user opens the file (Random.txt) successfully, your program should calculate the following:
A) The number of numbers in the file:
B) The sum of all the numbers in the file:
C) The average of all the numbers in the file:

Errors include:
project52.cpp: In function `int main()':
project52.cpp:9: error: expected initializer before '.' token
project52.cpp:10: error: ambiguous overload for 'operator>>' in 'std::cin >> randomtext'
/usr/local/gcc3/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.5/../../../../include/c++/3.4.5/bits/istream.tcc:87: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>&(*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/local/gcc3/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.5/../../../../include/c++/3.4.5/bits/istream.tcc:93: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_ios<_CharT, _Traits>&(*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/local/gcc3/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.5/../../../../include/c++/3.4.5/bits/istream.tcc:102: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base&(*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
/usr/local/gcc3/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.5/../../../../include/c++/3.4.5/bits/istream.tcc:417: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>] <near match>
project52.cpp:11: error: 'struct std::ifstream' has no member named 'c_str'
project52.cpp:14: error: `number' was not declared in this scope


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 #include <iostream>
 #include <string>
 #include <fstream>
  using namespace std;
  int main ()
   {
   cout << "Enter the file name " << endl;
   ifstream randomtext ;
   string randomtext.c_str() ;
  cin >> randomtext;
  randomtext.open(randomtext.c_str());
  if (randomtext)
  {
  while (randomtext >> number)
  {
  cout << number << endl;
  }
  randomtext.close();
  }
  else
  {
  cout << "There is an error opening the file." << endl;
  }
  return 0;
  }
Please do not post more than one thread: http://www.cplusplus.com/forum/beginner/161936/
Can I just delete the other one? This one is more detailed and I need help soon.
You already got an answer in your other topic, but you have abandoned it instead of providing further information.

Creating multiple threads to get attention is against the forum rules - we won't help you in this thread, but we will definitely try our best to help you in your original thread.
Topic archived. No new replies allowed.