Scanf/printf và cin/cout khác nhau như thế nào?

scanf/printf và cin/cout thì có nhanh hơn không ạ ? em không biết nó khác nhau cái gì

scanf and printf are two standard C functions used for formatted reading (input) and writing (output). For example, %f is the format template for floating-point numbers, and %s is for strings. Formatted means you can specify how the input or output is read or written. For example, %10s means reading a string 10 characters wide. Or %3.2f means a floating-point value with three digits before the decimal point and two after the decimal point.

in and out are C++ functions for input and output. The difference of in/out from scanf/printf is that the data is read or written as it is, and cannot be predefined as to how a value should be read or written.

Because C and C++ always go together. So they should be used accordingly. Don’t be confused by wannabe gurus who tell you that in/out is better than scanf/printf. That’s like comparing apples to oranges.

Which is faster? scanf/printf or in/out? The answer: C++ is based on C and is an OOL. In general, scanf/printf is faster than in/out.

1 Like

Bạn tham khảo vào đây xem

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?