*sigh* Using Namespace Std; Woes

This is a discussion on *sigh* Using Namespace Std; Woes within the C++ Programming forums, part of the General Programming Boards category; As suggested by Cat... I'm working on a simple XOR program (with some file i/o). It uses some include files. ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    42

    *sigh* Using Namespace Std; Woes

    As suggested by Cat...

    I'm working on a simple XOR program (with some file i/o). It uses some include files. Here they are:

    Code:
    #include <cstdlib>
    #include <fstream>
    #include <cstring>
    
    using namespace std;
    Now this does not compile. It throws errors at me, the same way as if I did not include <fstream> at all.

    I am pretty sure that it is not my programs logic because when I used ".h" it worked perfectly. *sigh*, why must I trouble myself so much just to use "ANSI" standard. It works don't it?

    I'll post some of the errors in a minute, Windows is freaking out on me. (As usual, Linux rules hehe)
    Sigh, nothing ever works the first try.

    Register Linux User #314127

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    42
    Some of the error messages:

    --'cout' : undeclared identifier
    --'<<' : illegal, right operand has type 'char [51]'
    Code:
    while(1)
    	  {
    		  cout << "Are you sure you want to encrypt this file (y/n)? ";

    --'nocreate' : is not a member of 'basic_ios<char,struct std::char_traits<char> >'
    --'nocreate' : undeclared identifier
    Code:
    if(!(strcmp(argv[i],"--decrypt")))
    		{
    			fstream FileD(argv[1], ios::in | ios::out | ios::nocreate);
    It was so much easier using the .h extensions.
    Sigh, nothing ever works the first try.

    Register Linux User #314127

  3. #3
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    first of all #include <iostream> that should fix your cout problem...according to my book ios::nocreate is not standard, but ios::in will not create and ios::in|ios:ut will not create anyway, so just remove ios::nocreate
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    42
    But fstream has cout/cin. Your right, iostream did work. But...nevermind, it works right?
    Sigh, nothing ever works the first try.

    Register Linux User #314127

  5. #5
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Originally posted by KneeLess
    But fstream has cout/cin. Your right, iostream did work. But...nevermind, it works right?
    fstream only has ofstream and ifstream; iostream has cin/cout.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why std:: and not using namespace std?
    By swappo in forum C++ Programming
    Replies: 4
    Last Post: 07-03-2009, 04:10 PM
  2. std:: or namespace std
    By C-+ in forum C++ Programming
    Replies: 16
    Last Post: 12-04-2007, 12:30 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 09:39 AM
  4. need ; before using namespace std
    By wwfarch in forum C++ Programming
    Replies: 7
    Last Post: 05-11-2004, 11:42 PM
  5. Site tutorials
    By Aalmaron in forum C++ Programming
    Replies: 20
    Last Post: 01-06-2004, 02:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21