473,324 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

fatal error-unexpected end of file while looking for precompiled header

1
fatal error-unexpected end of file while looking for precompiled header


Expand|Select|Wrap|Line Numbers
  1. Code :
  2. //                       BUDDY SYSTEM CODE
  3.  
  4. #include<stdio.h>
  5. #include<conio.h>
  6. int tree[2050],i,j,k;
  7. void
  8. segmentalloc(int,int),makedivided(int),makefree(int),printing(int,int);
  9. int place(int),power(int,int);
  10. main()
  11. {
  12.     int totsize,cho,req;
  13.     clrscr();
  14.     for(i=0;i<80;i++) printf("%c",5);
  15.     printf("
  16.             B U D D Y   S Y S T E M  R E Q U I R E M E N T 
  17. S
  18.  
  19. ");
  20.     for(i=0;i<80;i++) printf("%c",5);
  21.     printf("
  22.     *  Enter the Size of the memory  :  ");
  23.     scanf("%d",&totsize);
  24.     clrscr();
  25.     while(1)
  26.     {
  27.         for(i=0;i<80;i++) printf("%c",5);
  28.         printf("
  29.                  B U D D Y   S Y S T E M
  30.  
  31. ");
  32.         for(i=0;i<80;i++) printf("%c",5);
  33.         printf("
  34.  
  35.     *  1)   Locate the process into the Memory
  36. ");
  37.         printf("
  38.     *  2)   Remove the process from Memory
  39. ");
  40.         printf("
  41.     *  3)   Tree structure for Memory allocation Map
  42. ");
  43.         printf("
  44.     *  4)   Exit
  45.  
  46.  
  47. ");
  48.         for(i=0;i<80;i++) printf("%c",5);
  49.         printf("
  50.  
  51.     *  Enter your choice  :  ");
  52.         scanf("%d",&cho);
  53.         switch(cho)
  54.         {
  55.             case 1:
  56.                 clrscr();
  57.                 printf("
  58. ");
  59.                 for(i=0;i<80;i++) printf("%c",5);
  60.                 printf("
  61. ");
  62.                 printf("            M E M O R Y   A L L O C A T I O N 
  63.  
  64. ");
  65.                 for(i=0;i<80;i++) printf("%c",5);
  66.                 printf("
  67.  
  68.     *  Enter the Process size  : ");
  69.                 scanf("%d",&req);
  70.                 segmentalloc(totsize,req);
  71.                 break;
  72.             case 2:
  73.                 clrscr();
  74.                 printf("
  75. ");
  76.                 for(i=0;i<80;i++) printf("%c",5);
  77.                 printf("
  78. ");
  79.                 printf("            M E M O R Y   D E A L L O C A T I O N 
  80.  
  81. ");
  82.                 for(i=0;i<80;i++) printf("%c",5);
  83.                 printf("
  84.  
  85.     *  Enter the process size  :  ");
  86.                 scanf("%d",&req);
  87.                 makefree(req);
  88.                 break;
  89.             case 3:
  90.                 clrscr();
  91.                 printf("
  92. ");
  93.                 for(i=0;i<80;i++) printf("%c",5);
  94.                 printf("
  95.             M E M O R Y   A L L O C A T I O N   M A
  96.     P
  97.  
  98. ");
  99.                 for(i=0;i<80;i++) printf("%c",5);
  100.                 printf("
  101.  
  102. ");
  103.                 printing(totsize,0);
  104.                 printf("
  105.  
  106. ");
  107.                 for(i=0;i<80;i++) printf("%c",5);
  108.                 getch();
  109.                 clrscr();
  110.                 break;
  111.             default:
  112.                 return;
  113.         }
  114.     }
  115. }
  116.  
  117. void segmentalloc(int totsize,int request)
  118. {
  119.     int flevel=0,size;
  120.     size=totsize;
  121.     if(request>totsize)
  122.     {
  123.         printf("
  124.     %c  R E S U L T  :  
  125. ",2);
  126.         printf("
  127.     *  The system don't have enough free memory
  128. ");
  129.         printf("
  130.     *  Suggession  :  Go for VIRTUAL MEMORY
  131.  
  132. ");
  133.         getch();
  134.         return;
  135.     }
  136.     while(1)
  137.     {
  138.         if(request<size && request>(size/2))
  139.             break;
  140.         else
  141.         {
  142.             size/=2;
  143.             flevel++;
  144.         }
  145.     }
  146.     for(i=power(2,flevel)-1;i<=(power(2,flevel+1)-2);i++)
  147.         if(tree[i]==0 && place(i))
  148.         {
  149.             tree[i]=request;
  150.             makedivided(i);
  151.             printf("
  152.  
  153.      Result    :     Successful Allocation
  154.  
  155. ");
  156.             break;
  157.         }
  158.     if(i==power(2,flevel+1)-1)
  159.     {
  160.         printf("    %c    Result  :  ");
  161.         printf("
  162.     *  The system don't have enough free memory
  163.  
  164. ");
  165.         printf("
  166.     *  Suggession  :  Go for VIRTUAL Memory Mode
  167.  
  168. ");
  169.     }
  170. }
  171.  
  172. void makedivided(int node)
  173. {
  174.     while(node!=0)
  175.     {
  176.         node=node%2==0?(node-1)/2:node/2;
  177.         tree[node]=1;
  178.     }
  179. }
  180.  
  181. int place(int node)
  182. {
  183.     while(node!=0)
  184.     {
  185.         node=node%2==0?(node-1)/2:node/2;
  186.         if(tree[node]>1)
  187.             return 0;
  188.     }
  189.     return 1;
  190. }
  191.  
  192. void makefree(int request)
  193. {
  194.     int node=0;
  195.     while(1)
  196.     {
  197.         if(tree[node]==request)
  198.             break;
  199.         else
  200.             node++;
  201.     }
  202.     tree[node]=0;
  203.     while(node!=0)
  204.     {
  205.         if(tree[node%2==0?node-1:node+1]==0 && tree[node]==0)
  206.         {
  207.             tree[node%2==0?(node-1)/2:node/2]=0;
  208.             node=node%2==0?(node-1)/2:node/2;
  209.         }
  210.         else break;
  211.     }
  212. }
  213.  
  214. int power(int x,int y)
  215. {
  216.     int z,ans;
  217.     if(y==0) return 1;
  218.     ans=x;
  219.     for(z=1;z<y;z++)
  220.         ans*=x;
  221.     return ans;
  222. }
  223.  
  224. void printing(int totsize,int node)
  225. {
  226.     int permission=0,llimit,ulimit,tab;
  227.     if(node==0)
  228.         permission=1;
  229.     else if(node%2==0)
  230.         permission=tree[(node-1)/2]==1?1:0;
  231.     else
  232.         permission=tree[node/2]==1?1:0;
  233.     if(permission)
  234.     {
  235.         llimit=ulimit=tab=0;
  236.         while(1)
  237.         {
  238.             if(node>=llimit && node<=ulimit)
  239.                 break;
  240.             else
  241.             {
  242.                 tab++;
  243.                 printf("       ");
  244.                 llimit=ulimit+1;
  245.                 ulimit=2*ulimit+2;
  246.             }
  247.         }
  248.         printf(" %d ",totsize/power(2,tab));
  249.         if(tree[node]>1)
  250.             printf("---> Allocated %d
  251. ",tree[node]);
  252.         else if(tree[node]==1)
  253.             printf("---> Divided
  254. ");
  255.         else printf("---> Free
  256. ");
  257.         printing(totsize,2*node+1);
  258.         printing(totsize,2*node+2);
  259.     }
  260. }
Dec 21 '13 #1
1 2026
weaknessforcats
9,208 Expert Mod 8TB
I have a feeling that you are using Microsoft Visual Studio.NET and have created a Windows project instead of a console application project. This is true if your code has a #include for stdafx.h.

A Windows project has settings for Windows programs. One of these is pre-compiled headers.

The easiest solution is to create a new project as a Win32 Console Application but before clicking Finish in the wizard, select Next and uncheck "Precompiled headers". Then click Finish.

You can also avoid those Windows-only files like stdafx.h by clicking Empty Project before clicking Finish.
Dec 21 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Newsgroup - Ann | last post by:
I have a library function like GetOptions( ..., struct net_arch_t netArch, ....) and put the declaration into a regular header file like getopt.h. But this function declaration also needs the...
16
by: Michael | last post by:
I have a data application in a2k that I need to create two fixed width text files and then combine them to a single file The first file is header information and the second is transaction data. ...
4
by: Andrew Ward | last post by:
Hi All, I was wondering if it is possible to use precompiled headers without having to include a <stdafx.h> or whatever in every source file. My problem is that I have a project that makes heavy...
0
by: Bruno van Dooren | last post by:
Hi, I am working on a dll that exports COM interfaces, and i am having some troubles with the use of precompiled headers. the project compiles always, but if i use /Yu (default: use precompiled...
2
by: Tommy Vercetti | last post by:
I am working on a Managed C++ project and I get the following error: TestThread.cpp(3) : error C2859: c:\projects\ProjectName\debug\vc70.pdb is not the pdb file that was used when this...
2
by: Lloyd Dupont | last post by:
I'm using VS.NET 2005 beta 2. I have problem compiling project (it says: 'cannot find file StdAfx.h" which is right in the middle of my project). The 1st time I create a new project and it fixes...
1
by: CJM | last post by:
I've copied (& modified) some code from MSDN which uses a Repeater control, but I'm getting an error: Unexpected end of file looking for </HeaderTemplate> As far as I can see I've not made an...
4
by: pamela fluente | last post by:
I have created and published a precompiled application. If I replace an ASP file, e.g. Default.ASP, with a new copy, by sending it via FTP, do I do something WRONG? Do I spoil the precompiled...
0
by: ma740988 | last post by:
Section 6.5 of Josuttis, C++ Templates states - and I paraphrase. "Let's assume for the sake of argument that every file to be compiled starts with the same N lines of code. We could compile...
5
by: dm3281 | last post by:
Hello, I have a text report from a mainframe that I need to parse. The report has about a 2580 byte header that contains binary information (garbage for the most part); although there are a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.