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 6776789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:04:14+00:00 2026-05-26T16:04:14+00:00

This code run on Turbo C but not on gcc compiler Error:syntax error before

  • 0

This code run on Turbo C but not on gcc compiler

Error:syntax error before ‘*’ token

#include<stdio.h>
int main()
{
char huge *near *far *ptr1;
char near *far *huge *ptr2;
char far *huge *near *ptr3;
printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));
return 0;
}

Turbo C output is :4, 4 , 2
Can you explain the Output on Turbo C?

  • 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-05-26T16:04:15+00:00Added an answer on May 26, 2026 at 4:04 pm

    Borland’s C/C++ compilers for DOS supported multiple memory models.

    A memory model is a way to access code and data through pointers.

    Since DOS runs in the so-called real mode of the CPU, in which memory is accessed through pairs of a segment value and an offset value (each normally being 16-bit long), a memory address is naturally 4 bytes long.

    But segment values need not be always specified explicitly. If everything a program needs to access is contained within one segment (a 64KB block of memory aligned on a 16-byte boundary), a single segment value is enough and once it’s loaded into the CPU’s segment registers (CS, SS, DS, ES), the program can access everything by only using 16-bit offsets. Btw, many .COM-type programs work exactly like that, they use only one segment.

    So, there you have 2 possible ways to access memory, with an explicit segment value or without.

    In these lines:

    char huge *near *far *ptr1;
    char near *far *huge *ptr2;
    char far *huge *near *ptr3;
    

    the modifiers far, huge and near specify the proximities of the objects that ptr1, ptr2 and ptr3 will point to. They tell the compiler that the *ptr1 and *ptr2 objects will be “far away” from the program’s main/current segment(s), that is, they will be in some other segments, and therefore need to be accessed through 4-byte pointers, and the *ptr3 object is “near”, within the program’s own segment(s), and a 2-byte pointer is sufficient.

    This explains the different pointer sizes.

    Depending on the memory model that you choose for your program to compile in, function and data pointers will default to either near or far or huge and spare you from spelling them out explicitly, unless you need non-default pointers.

    The program memory models are:

    • tiny: 1 segment for everything; near pointers
    • small: 1 code segment, 1 data/stack segment; near pointers
    • medium: multiple code segments, 1 data/stack segment; far code pointers, near data pointers
    • compact: 1 code segment, multiple data segments; near code pointers, far data pointers
    • large: multiple code and data segments; far pointers
    • huge: multiple code and data segments; huge pointers

    Huge pointers don’t have certain limitations of far pointers, but are slower to operate with.

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

Sidebar

Related Questions

this code run firefox , but error on ie why ? please help me.
When I run this code the selected item is not visible. I've already tried
when i run this code : CONADefinitions.CONAPI_FOLDER_INFO2 FolderInfo; int iResult = 0; IntPtr Buffer
So far I have this code run when the X button is clicked, but
In .Net 4 this code run with no error class A { public event
I'm using ksh and having some trouble. Why does this code not run? [root]$
I want to make this code run, but I'm still too much of a
Why does the following code run? #include <iostream> class A { int num; public:
Consider the following code: #include <stdio.h> int main() { printf(%d, 300 * 300 /
I have this code to run a slideshow (this is only part of what

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.