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

  • Home
  • SEARCH
  • 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 8581063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:57:37+00:00 2026-06-11T20:57:37+00:00

#include <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> extern char **environ; int global_x =

  • 0
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

extern char **environ;

int global_x = 10;                  // initialised global variable
int global_y;                       // un-initialised global variable
char global_array1[] = "Hello, world!";     // initialised global array and a string literal
char global_array2[10];             // un-initialised global array
char *global_pointer1 = "bye!";         // global pointer to a string literal 
char *global_pointer2;              // un-initialised global pointer 
float global_float = 100.1;         // initialised global variable
double global_double;               // un-initialised global variable

#define ONEGB  1073741824
#define ONEMB  1048576
#define ONEKB  1024

char *addr(unsigned long a)
{
    unsigned long r; // remainder

    r = (unsigned long) a;
    int gb = (int) ( r / ONEGB );

    r -=  gb * ONEGB;
    int mb = (int) ( r  / ONEMB );

    r -=  mb * ONEMB;
    int kb = (int) ( r  / ONEKB );

    r -=  kb * ONEKB;
    int b  = (int) ( r );

    char *p = malloc(64);

    sprintf(p, "%4dGB, %4dMB, %4dKB, %4d", gb, mb, kb, b);
    return p;
}

int f2(int x)
{
    char * f2_p;
    int f2_x = 21;

    f2_p = malloc(1000);         // dynamically allocated memory

    // print out the address of x
    // print out the addresses of f2_p, and f2_x
    // print out the starting address of the dynamically allocated memory
    .....

    L: f2_x = 10;
    return f2_x;
}

void f1(int x1, int x2, float x3, char x4, double x5, int x6)
{
    int f1_x = 10;
    int f1_y;
    char *f1_p1 = "This is inside f1";   // pointer to another string literal 
    char *f1_p2;

    f1_p2 = malloc(100);         // dynamically allocated memory

    // print out the addresses of x1, x2, x3, x4, x5, x6
    // print out the addresses of f1_x, f1_y, f1_p1, f1_p2
    // print out the address of the string literal "This is inside f1"
    .....

    f1_y = f2(10);
    return;
}

int main(int argc, char *argv[])
{

    // print out the addresses of argc, argv
    // print out the starting address and end address of the command line arguments of this process
    // print out the starting address and end address of the environment of this process
    // print out the starting addresses of function main, f1, and f2
    // print out the addresses of global_x, global_y, global_array1, global_array2, global_pointer1,
    //           global_pointer2, global_float, global_double
    // print out the addresses of string literals 10, "Hello, world!", "bye", 100.1

    ..... 

    // call function f1 with suitable arguments such as 12, -5, 33.7, 'A', 1.896e-10, 100 
    f1( .... );

    exit(0);
}

I tried to search on google, but cannot find sth useful, and in this case I just want to figure out how to print out the starting address of the dynamically allocated memory; print out the starting address and end address of the command line arguments of this process;print out the starting address and end address of the environment of this process;print out the starting addresses of function main, f1, and f2.
anybody can help me?..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-11T20:57:38+00:00Added an answer on June 11, 2026 at 8:57 pm

    In main :

    print out the addresses of argc, argv – printf ("%d, %d", &argc, argv);

    print out the starting address and end address of the command line arguments of this process – printf ("%d", (void *)argv);

    print out the starting address and end address of the environment of this process – printf ("%d", (void *)environ);

    print out the starting addresses of function main, f1, and f2 – printf ("%d %d %d", &main, &f1, &f2);

    print out the addresses of global_x, global_y, global_array1, global_array2, global_pointer1, global_pointer2, global_float, global_double – just use the & operator in front of each variable whose address you want to print.

    print out the addresses of string literals 10, "Hello, world!", "bye", 100.1 – printing addresses of string literals is not allowed.

    In f1:

    print out the addresses of x1, x2, x3, x4, x5, x6 – printf ("%d %d %d %d %d %d", &x1, &x2, &x3, &x4, &x5);

    print out the addresses of f1_x, f1_y, f1_p1, f1_p2 – printf ("%d %d %d %d", &f1_x, &f1_y, f1_p1, f2_p2);

    print out the address of the string literal "This is inside f1" – Taking address of a string literal is not allowed

    In f2:

    print out the address of x – printf ("%d", &x);

    print out the addresses of f2_p, and f2_x – printf("%d", f2_p, &f2_x);

    print out the starting address of the dynamically allocated memory – printf ("%d", f2_p);

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

Sidebar

Related Questions

#include<stdio.h> #include<string.h> #include<stdlib.h> int main() { // int char str[40],ch; FILE*fp,*fp1,*fp2; fp=fopen(ide_input,w); fp1=fopen(error_log,w); fp2=fopen(lex_output,w);
Possible Duplicate: Getting Segmentation Fault // reverse a string #include`<stdlib.h>` #include`<stdio.h>` #include`<string.h>` #include`<math.h>` int
#include<stdio.h> #include<stdlib.h> char* re() { char *p = hello; return p; } int main()
#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { if(argc != 2) return
#include stdafx.h #include stdio.h #include math.h #include stdlib.h void test (int a,int *b, int
The code: #include stdafx.h #include stdio.h #include math.h #include stdlib.h #include time.h int main()
Here is my perceptron implementation in ANSI C: #include <stdio.h> #include <stdlib.h> #include <math.h>
#include <stdio.h> #include <stdlib.h> int main(void) { int x; int *in, *begin; in =
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *next; }; void insert( struct
#include <stdio.h> #include <stdlib.h> #include <time.h> void initDeck (int deck[]); void showDeck (int deck[]);

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.