scr*_*ord 1 c pointers function memory-address
我在main中有一个名为'end'的int.
主函数调用函数,函数本身调用函数.
到目前为止,我能够让第一个函数通过向它发送一个地址并让它期望一个指针来操纵'结束'.然而,我无法将其发送到下一个函数,并让它操纵main中调用的'int'.
到目前为止,我有以下哪个适用于一个功能;
适用于一个功能的缩写代码:
void function(int* end);
int main(void)
{
end = 0;
function(&end);
}
void function(int* end)
{
*end = 1;
// At this stage I want to call in another function, and have it be able to manipulate 'end'
}
Run Code Online (Sandbox Code Playgroud)
只是继续传递指针.
void function2( int *end ) {
*end += 41;
}
void function( int *end ) {
*end = 1;
function2( end );
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
224 次 |
| 最近记录: |