首页 > 解决方案 > 关于“int”的问题。整数与 C 中的初始化

问题描述

我对在声明整数和使用它来初始化变量时如何区分“int”的使用感到困惑。

在以下示例中,我相信我正在初始化变量 n、m、y:

int main(void)
    {
    int n,m,y ;
}

如何区分“整数”和“初始化”

谢谢

标签: cintegerinitializationcs50

解决方案


int foobar; //this is a declaration of an integer variable 

foobar = 42; // this is assignment of the variable 

int x = 52; // this is declaration and initialization in one line so you perform two things in this line: declaration and initialization to value 52

推荐阅读