1.
2.
void fun (void) / / 函数头,无分号
{
printf ( “Hellow world! \n” ); / / 函数体
}
解析:
A.第一个 void :函数返回值,void 表示无返回值。():叫做参数列表,传递参数的,无参数就写个 void。
B.printf ( “Hellow world! \n” ); / / 函数体
C.fun: 函数的名字
3.
- int main(void)
- {
- int Status;
- volatile int Delay;
-
- /* Initialize the GPIO driver */
- Status = XGpio_Initialize(&Gpio, GPIO_EXAMPLE_DEVICE_ID);
- if (Status != XST_SUCCESS) {
- xil_printf("Gpio Initialization Failed\r\n");
- return XST_FAILURE;
- }
-
- /* Set the direction for all signals as inputs except the LED output */
- XGpio_SetDataDirection(&Gpio, LED_CHANNEL, ~LED);
-
- /* Loop forever blinking the LED */
-
- while (1) {
- /* Set the LED to High */
- XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, LED);
-
- /* Wait a small amount of time so the LED is visible */
- for (Delay = 0; Delay < LED_DELAY; Delay++);
-
- /* Clear the LED bit */
- XGpio_DiscreteClear(&Gpio, LED_CHANNEL, LED);
-
- /* Wait a small amount of time so the LED is visible */
- for (Delay = 0; Delay < LED_DELAY; Delay++);
- }
-
- xil_printf("Successfully ran Gpio Example\r\n");
- return XST_SUCCESS;
- }
解析:——有返回值(return XST_SUCCESS)无参数
int main(void)——第一个 int :函数返回值
4.
前置自增++a是先自增,再判断,再进入循环体;
后置自增a++是先判断,再自增,再进入循环体;