The purpose of this code is to pass a virtual address in decimal and output the page number and offset.
After I compile my code using the gcc compiler on Linux I get this error:
indirection requires pointer operand (‘int’ invalid) virtualAddress = *atoi(argv[1]);
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <curses.h>
int main(int argc,char *argv[])
{
unsigned long int virtualAddress,pageNumber,offset;
if(argc<2){
printf(" NO ARGUMNET IS PASSED");
return 0;
}
virtualAddress = *atoi(argv[1]);
//PRINT THE VIRTUAL ADDRESS
printf("The Address %lu contains:",virtualAddress);
//CALCULATE THE PAGENUMBER
pageNumber = virtualAddress/4096;
//PRINT THE PAGE NUMBER
printf("\n Page Number = %lu",pageNumber);