0

In the following program, when I enter a number I'M getting strange output back. When I enter 5 I get 0x6011a85 back on the cout << "you entered" line.

#include <iostream>
//#include "functions.h"

int main()
{
    std::cout << "Please enter a number. " << std::endl;
    int date = 0;
    std::cin >> date;
    std::cout << "You entered" << std::cout << date;
}

// FUNCTIONS

/*int getNrDigits( int my_int )
{
    int local_int = my_int;
    int count = 0;

    while ( local_int > 0 )
    {
        local_int /= 10;
        count++
    }
    return count;
} */

Edited by Dani: Formatting fixed

3
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by CGSMCMLXXV
1

std::cout << "You entered" << std::cout << date;

There is the problem. Try:

std::cout << "You entered" << date;

(without the second cout)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.