How to go to the previous line in a C code

后端 未结 7 2023
渐次进展
渐次进展 2021-01-14 11:14

If for the following code:

printf(\"HEllo\\n\");    // do not change this line.
printf(\"\\b\\bworld\");

I need an output: Helloworld (In a

7条回答
  •  悲哀的现实
    2021-01-14 11:53

    Remove "\n" from your first printf. It moves the cursor to a new line.

    Here is the list of escape sequences.

    If you can't remove "\n", then you can do make a copy of a substring without these charaters. See the following example:

      const char* from = "12345678";
      char *to = (char*) malloc(6);
      strncpy(to, from+2, 5);
    

    All you need is to determine the index of "\n" characters.

提交回复
热议问题