How to create a table of this given code in c? -


how can arrange in table address value , name appears in proper rows columns ?

#include <stdio.h> #include <stdlib.h> #include <conio.h> int main() { int tuna = 20; printf("adress \t name \t value \n"); printf("%p \t %s \t %d \n",&tuna , "tuna", tuna);  int * ptuna = &tuna;  printf("%p \t %s \t %d \n", ptuna, "tuna", tuna); printf("%p \t %s \t %p \n", &ptuna, "tuna", ptuna);   _getch(); return 0; } 

i modified program follows. here %-15 make sure data printed in 15 character field left indentation. of'course assumption took here data fit in 15 characters field. might want change per requirement.

#include <stdio.h> #include <stdlib.h> #include <conio.h> int main() { int tuna = 20; printf("%-15s %-15s %-15s \n","address","name","value"); printf("%-15p %-15s %-15d \n",&tuna , "tuna", tuna);  int * ptuna = &tuna;  printf("%-15p %-15s %-10d \n", ptuna, "tuna", tuna); printf("%-15p %-15s %-15p \n", &ptuna, "tuna", ptuna);   _getch(); return 0; } 

and output get:

address         name            value            0xbffff510      tuna            20               0xbffff510      tuna            20          0xbffff50c      tuna            0xbffff510       

i hope looking for.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -