Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8879255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:54:39+00:00 2026-06-14T19:54:39+00:00

Code: #include <cstdlib> #include <iostream> #define PI 3.14159 using namespace std; int main(int argc,

  • 0

Code:

#include <cstdlib>
#include <iostream>
#define PI 3.14159

using namespace std;

int main(int argc, char** argv) {    
    cout<<"Address of PI:"<<&PI<<endl;    
    return 0;
}

Here is the output:

main.cpp: In function int main(int, char**)':
main.cpp:20: error: non-lvalue in unary
&’
make[2]: * [build/Debug/Cygwin-Windows/main.o] Error 1
make[1]:
[.build-conf] Error 2
make: *
* [.build-impl] Error 2

So why can’t I see the memory address of PI here?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:54:41+00:00Added an answer on June 14, 2026 at 7:54 pm

    Macros are never allocated a memory. Before the code is compiled, the compiler does a text search in the file and replace all Macros with their value. Also this is a text search, so the text gets replaced. So PI gets replaced by 3.14 in your code before compiling it. As a result, the memory operator throws an error because it cannot get the value of 3.14 as it is not a variable. Hope it helps 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have following code #include <iostream> #include <cstdlib> using namespace std; int main() {
Code looks like that #include <cstdlib> #include <iostream> using namespace std; #define n 3;
Example code: #include <cstdlib> #include <iostream> using namespace std; class A { public: A(int
I am running this code: #include <iostream> #include <cstddef> int main(int argc, char *argv[]){
Here is my code: #include <cstdlib> #include <iostream> #include <cstring> using namespace std; int
I've try to compile this code: #include <iostream> #include <cstdlib> using namespace std; #define
The following code: #include <cstdlib> #include <iostream> using namespace std; int function(void) { static
The code #include <QtCore> #include <QtXml/QDomElement> int main(int argc, char *argv[]) { QCoreApplication app(argc,
so I execute this code #include <cstdlib> #include <iostream> int main() { char *test
I have the following code: #include <cstdlib> #include <iostream> #include <stdlib.h> using namespace std;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.