-
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.
-
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);
-
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...
-
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.
-
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"
-
To learn C language strings, enter a specified string and calculate the number of digits of the string.
Do you mean to say that a is a value of 10 or does a literally mean 10? >>>More
Use the ITOA function.
Prototype: extern char *itoa(int i); >>>More
Just take a look at this one**.
Hope it helps. >>>More
<> output conforms to the example, hope
Source code: include >>>More
if(strcmp(*n[i],*n[j]))temp=n[i]; n[i]=n[j]; n[j]=temp;
Here's the problem. >>>More