Unlimited Zone
Home WebHosting GilbertArevaloGang Search Members Calendar Help Time: 06-20-2013, 03:36 PM 


Forgot Password?Register
Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
c++ code error !!
08-10-2011, 05:31 PM (This post was last modified: 08-10-2011 05:31 PM by aizirc.)
Post: #1
c++ code error !!
#include <stdio.h>
#include <conio.h>
#include <malloc.h>

main()
{
int *base; // A
int i;
int cnt=0;
int sum=0;
printf("how many integers you have to store \n");
scanf("%d",&cnt); // B
base = (int *)malloc(cnt * sizeof(int)); // C
printf("the base of allocation is %16lu \n",base); // D
if(!base) // E
printf("unable to allocate size \n");
else
{
for(int j=0;j<cnt;j++) // F
*(base+j)=5;
}
sum = 0;
for(int j=0;j<cnt;j++) // G
sum = sum + *(base+j);
printf("total sum is %d\n",sum); free(base); // H
printf("the base of allocation is %16lu \n",base);
base = (int *)malloc(cnt * sizeof(int));
printf("the base of allocation is %16lu \n",base);
base = (int *)malloc(cnt * sizeof(int)); // I
printf("the base of allocation is %16lu \n",base);
base = (int *)calloc(10,2); // J
printf("the base of allocation is %16lu \n",base);

getche();
return 0;
}


pano po mapagana 2???neded help!
Find all posts by this user
Quote this message in a reply
08-31-2011, 08:59 AM
Post: #2
RE: c++ code error !!
aw may mali sa end ng code mo tol

Quote:getche();
return 0;
}

it should be like this

Code:
Only registered members can see this link.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)