c This is a question about language local variables.

Asked 1 weeks ago, Updated 1 weeks ago, 1 views

#include <stdio.h>

void TestLocal();

int main(){

  return 0;

void TestLocal(){
  int num=0;


The result of the code is 0,0 and num++ increases the value of num in the book's commentary, but it is hard to understand that the increased value disappears because the num is released when the function returns. Please solve it.

p.s. num++ is a grammar structure that outputs num==0 first and then num+1? I think it'll be fine if this part is resolved.


2022-09-20 11:31

1 Answers

"num++ is a grammatical structure that outputs num==0 and then num+1. "

Instead of num++, try ++num and the result will be different.

2022-09-20 11:31

If you have any answers or tips

© 2022 pinfo. All rights reserved.