Thread: qusetion?

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    142

    qusetion?

    is seekg and seekp only used for veriables or can you use them for characters as well, if you can't is there a function that does the same type of thing.

    cheers wart1010101010101010100011101
    WhAtHA hell Is GoInG ON

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    neither. They are used for moving to a new location in data files. see fstream descriptions.

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    142

    ok

    sorry i didn't ask the question properly i wanted to know if you could use the seekp and seekg functions to output characters or is it just used for variables. and i do apolagise as i am a newbie....
    WhAtHA hell Is GoInG ON

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    I'll repeat what was said earlier:

    Quote Originally Posted by Ancient Dragon
    neither. They are used for moving to a new location in data files. see fstream descriptions.
    The seekp and seekg functions are only used to move the put/get pointers within a stream. The functions you would use to perform actual output would typically be either the stream's insertion operator(<<), or the put member function. They can all be used with either a variable or a hardcoded value:

    Code:
    char c = 'A';
    ofstream strm("file.txt");
    
    strm.put('B');  // Writes the character 'B' to the stream
    strm.put(c);    // Writes the character 'A' to the stream
    strm << 'B';    // Writes the character 'B' to the stream
    strm << c;      // Writes the character 'A' to the stream
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    142
    ok soz,,thats much clearer,,,,,,,,,,,,,,,,,cheers
    WhAtHA hell Is GoInG ON

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Qusetion about sending VK_CONTROL
    By tjpanda in forum Windows Programming
    Replies: 4
    Last Post: 12-04-2008, 01:06 PM
  2. Qusetion related to shared memory
    By g_p in forum C Programming
    Replies: 1
    Last Post: 12-03-2006, 06:09 AM
  3. Qusetion on Class/Struct program
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 05-05-2002, 12:04 AM