How to input two lines of strings in the C language?

In C language, you can use the scanf() function to input strings. To input two lines of strings, you can follow these steps:

  1. str1: Please rephrase the following text in English.
  2. str2: “There is a problem with my car.”
  3. capture input
  4. %s
  5. Read input from the user and store it in the variable str1.
  6. read a line from a file
  7. read input from the user
  8. Read a line of input from the standard input and store it in the string variable str1.
  9. str1: implement the changes according to the new regulations.
  10. Convert string2 to English.

Here is a complete example code:

#include <stdio.h>

int main() {
    char str1[100];
    char str2[100];

    printf("请输入第一行字符串:");
    scanf("%s", str1);

    printf("请输入第二行字符串:");
    scanf("%s", str2);

    printf("第一行字符串:%s\n", str1);
    printf("第二行字符串:%s\n", str2);

    return 0;
}

After running the program, it will prompt you to enter two lines of text, and then it will print out each inputted string separately.

bannerAds