Why use format strings in C

Updated on technology 2024-05-17
6 answers
  1. Anonymous users2024-02-10

    Because each piece of data is stored differently in memory, the same piece of data has different meanings in different types.

    For example, in your example %d, 65 will output the number 65, and if you are %c in your example, 65 will be interpreted as saying that the argument after the letter aprintf function just passes an address. printf doesn't know the type of data you're passing, so you need to mark your type in the string.

    I hope you understand.

  2. Anonymous users2024-02-09

    The computer can only use binary to represent the original number, and people have designed octal, decimal and hexadecimal systems for convenience.

    Generally, the decimal system is used, and the size of the number is different in the computer, you can't always use the same large storage space for 1 and 1 billion, so it's too wasteful, so I designed the 15th power of the deputy 2 minus one to the 15th power of the positive 2 minus one bit a file, represented by d, is a substitute, the printf function stipulates that the number represented by the substitute is after the quotation marks, if not, it will burst out of error.

    printf(“sum is %d”,sum);

  3. Anonymous users2024-02-08

    d represents the output of an integer number... And you have a mistake that should be in double quotes, because double quotes are the output, and the line breaks also belong to... It should also be followed by the address of the word %d...

  4. Anonymous users2024-02-07

    You can use arrays or pointers.

    Array: char s[80]="abcd";or char s[80]=; Note: Auto-add string end flag: 0*

    char s[80]=;

    pointer: char *s; char*s="abcd";

    C is a general-purpose computer programming language with a wide range of applications. C is designed to provide a programming language that can compile in a simple way, handle low-level memory, generate a small amount of machine code, and run without any runtime support.

    Although C provides many low-level processing functions, it still maintains a good cross-platform characteristic, and C programs written in a standard specification can be compiled on many computer platforms, including some embedded processors (microcontrollers or MCUs) and supercomputers.

    In the 80s of the twentieth century, in order to avoid the differences in the C language grammar used by various developers, the National Bureau of Standards of the United States formulated a complete set of international standard grammar for the C language, called ANSI C, as the original standard for the C language.

  5. Anonymous users2024-02-06

    You can define a string with an array of characters or a character pointer, or you can define a constant string with a macro definition.

    Let's take a look at each of them with examples:

    char str1 = "helloworld";A string is defined by an array of characters"helloworld", one character per memory cell in the array.

    char *str2 = "helloworld";Character pointers are used to define strings"helloworld", pointer str2 points to a storage string"helloworld"The first address of the contiguous address unit.

    #define str3 "helloworld";Strings are defined by macro definitions"helloworld", equivalent to str3="helloworld"

  6. Anonymous users2024-02-05

    To learn C language strings, enter a specified string and calculate the number of digits of the string.

Related questions
25 answers2024-05-17

Do you mean to say that a is a value of 10 or does a literally mean 10? >>>More

6 answers2024-05-17

Use the ITOA function.

Prototype: extern char *itoa(int i); >>>More

4 answers2024-05-17

Just take a look at this one**.

Hope it helps. >>>More

4 answers2024-05-17

<> output conforms to the example, hope

Source code: include >>>More

5 answers2024-05-17

if(strcmp(*n[i],*n[j]))temp=n[i]; n[i]=n[j]; n[j]=temp;

Here's the problem. >>>More