Steam Help...

This is a discussion on Steam Help... within the C++ Programming forums, part of the General Programming Boards category; I'm working on an assignment which I have to first read in a char type-output it, then read in a ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    9

    Steam Help...

    I'm working on an assignment which I have to first read in a char type-output it, then read in a int type...

    This is some of what I coded (btw i just started coding so please no negative comments):

    Code:
    	char nextchar;
    	int nextint;
    	
    
    	in_stream.get(nextchar);
    	while (! in_stream.eof( ))
    	{
    		if (nextchar != 'S')
    		{
    			out_stream.put(nextchar);
    			in_stream.get(nextint);
    		}



    With the code like that I keep getting this error:
    "error C2664: 'class std::basic_istream<char,struct std::char_traits<char> > &__thiscall std::basic_istream<char,struct std::char_traits<char> >::get(char &)' : cannot convert pa
    rameter 1 from 'int' to 'char &'"




    Can someone PLEASE help me out with this...


    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    First, whenever you want help with an error, post the error AND a comment in your code on the line the error occurs to indicate where the error is to someone trying to help you.

    Your problem is here:

    in_stream.get(nextint);

    nextint is an integer type and the function get() needs a char type as a parameter.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    9
    Originally posted by 7stud
    First, whenever you want help with an error, post the error AND a comment in your code on the line the error occurs to indicate where the error is to someone trying to help you.

    Your problem is here:

    in_stream.get(nextint);

    nextint is an integer type and the function get() needs a char type as a parameter.
    Thanks for the reply & sorry for not posting my problem correctly.

    Can you (or someone else) help me out so I can take in the next 'int', so I can use it.

    The file I'm reading from is in this format:
    (char)(char) (int) (int)

    I know how to take in the two char files but (as you can see) I'm stuck at taking in the ints.

    So, if someone can help me-please do...

    Thanks a million...

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    instream >> nextint;

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    If there are spaces between each char and each int, you can read in one line of input like this:

    in_stream>>first_char>>second_char>>first_int>>sec ond_int;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No SecuROM on Sims 3
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 68
    Last Post: 05-20-2009, 05:43 PM
  2. Fuming on Steam
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 31
    Last Post: 07-01-2008, 05:26 PM
  3. New levels of retardedness
    By abachler in forum A Brief History of Cprogramming.com
    Replies: 108
    Last Post: 03-26-2008, 03:08 PM
  4. bad and fail of steam
    By George2 in forum C++ Programming
    Replies: 8
    Last Post: 02-19-2008, 02:07 AM
  5. How to define a variant record type in C
    By Diepvien_007 in forum C Programming
    Replies: 2
    Last Post: 03-12-2003, 03:23 PM

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