also whats the difference between
Code: Select all
this;
Code: Select all
*this
Code: Select all
this;
Code: Select all
*this
Code: Select all
void print(char* s, int size)
{
for (char* p = s; p < s + size; p++)
{
_putch(*p);
}
}
void scan(char* buf)
{
for (char c = _getch(); _getch() != 13; buf++)
{
_putch(c);
}
}
int main()
{
print("Enter a number :", 18);
char m[1000];
char* msg = m;
scan(msg);
print("\nYou typed :", 15);
print(msg, 100);
while (!_kbhit())
{
;
}
return 0;
}
Code: Select all
void scan(char* buf)
{
for (char c = _getch(); _getch() != 13; buf++)
{
_putch(c);
}
}
Code: Select all
while (!_kbhit())
Code: Select all
void scan( char* buf )
{
for( char c = _getch(); _getch() != 13; buf++ )
{
_putch( c );
}
}
Yeah, since C++ is compatible with C, functions like printf/fprintf/scanf/fscanf made their way into the C++ library also. With C++ you can use other utility functions and classes like std::string, std::stringstream, std::iostream and std::fstream. There are two global iostream objects for getting and setting user input to the console; std::cin and std::cout. Chili covers these a bit later in the tuts along with stringstream and fstream for strings and file access.Empirean wrote:I named it "scan" cause in turboC the function is called scanf.