/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
Gabriel Staples
www.ElectricRCAircraftGuy.com
20 Dec. 2020
Share link: https://onlinegdb.com/HyRgJN63D
*******************************************************************************/
#include <stdio.h>
struct MyStruct
{
int a;
int b;
};
void myFunc(const MyStruct* myStruct)
{
printf("%i\n", myStruct->a); // ok
// myStruct->a = 10; // NOT OK!--myStruct points to a const struct so the
//struct cannot be modified here!
}
int main()
{
MyStruct s;
s.a = 100;
myFunc(&s);
s.a = 200;
myFunc(&s);
return 0;
}
/*
OUTPUT:
100
200
*/