C ++帮助我理解为什么没有输出

c++ help me to understand why there is no output

本文关键字:为什么 输出 帮助      更新时间:2023-10-16

这个程序很简单:1(取一个输入字符串。2(将其转换为长.3(打印转换结果。

期望输出,但未找到。

            #include <stdio.h>
            #include <string>
            using namespace std;
         int main()
              {
               string ch;
               scanf("%s",ch);
               long l=stol(ch);
               printf("%l",l);
               return 0;
              }
以下是如何使用

C++ I/O完成此操作。在C++程序中使用 C I/O 的理由很少。

#include <iostream>
#include <string>
int main()
{
    std::string input;
    std::cin >> input; // take an input string
    long lval = stol(str); // convert to long
    std::cout << lval << 'n' // print the result
}

现在这些东西将在任何C++本书的第一章中介绍。一本好书将大大提高你学习C++的速度和程度。