नीचे कोड का आउटपुट 2500 है। इसमें पॉइंटर्स हैं। क्या कोई इस बारे में उचित स्पष्टीकरण दे सकता है? यह 2500 के रूप में क्यों प्रिंट करता है? क्या यह सूचक घोषणा के माध्यम से आता है या कोई और कारण है?क्या यह गलत होगा? और यदि ऐसा है तो यह क्यों है? आउटपुट 2500
#include <stdio.h>
/* Two functions include and they are operated by main function */
int *f(int x) {
/* Creates an variable */
int p;
p = x;
return &p;
}
/* Here the initialization of the function g */
int *g(int x) {
/* Creates an variable */
int y;
y = x;
return &y;
}
/* This creates two pointers called x and y */
int main() {
int *x, *y;
/* Here call the functions f and g */
x = f(100);
/* Here call the function g */
y = g(2500);
/* How does it print 2500? */
/* print the value of x */
printf("%d \n", *x);
return 0;
}
'जोर दें (x == y);' –
@DanLowe धन्यवाद। इसके लिए और टाइपो को ठीक करना भी :) –
सभी चेतावनियों और डीबग जानकारी (उदाहरण के लिए 'gcc -Wall -Wextra -g' [GCC] (http://gcc.gnu.org/) का उपयोग करते हुए संकलित करें ...) तो ** डीबगर ** ('gdb') –