Using Pointer

Monday, October 19, 2009

This will show You about simple using pointer in C.


int main(void){
    int y, x = 87;
    int *px;

    px = &x;
    y = *px;

    printf("Giving x = 87 (integer)\n");
    printf("px = &x;\n");
    printf("y = *px;\n\n");
    printf("Address of x = %p\n", &x);
    printf("Content of px = %p\n", px);
    printf("Content of x = %d\n", x);
    printf("Value that being pointed by px = %d\n", *px);
    printf("Value of y = %d\n", y);

    return 0;

Dayung Sampan

Monday, October 12, 2009

I'm listening to the Indonesia Folk Song, called "Dayung Sampan". This song accompany me during finishing my last task..:)

Copying Array to Another Array

This code will explain You how to copy from one array to another array..

#define MAKS 30

int main(void){
    int i;
    char asal[] = "I like C...";
    char hasil[MAKS];

    i = 0;
    while(asal[i] != '\0'){
        hasil[i] = asal[i];

    hasil[i] = '\0'; // give null char
    printf("Content of hasil: %s\n", hasil);

    //return 0;

Another Code to Count Char in A Sentence

Saturday, October 10, 2009

This is the another method, we are using string.h


char line[100]; //max 100 chars of input

int main(void){
    printf("Enter the sentence: \n");
    fgets(line, sizeof(line), stdin);

    printf("The length of the sentence is: %d\n", strlen(line));
    return 0;

How to Count Char on Input Sentence

This is one ef the C code that will count the char of sentence that we've input before.

#define MAKS 256

int main(void){
    int i, jumkar = 0;
    char teks[MAKS];

    puts("Please insert a sentence (max 256 char): ");
    puts("I'll count sum of char on its sentence. ");
    fgets(teks, sizeof teks, stdin); //input from keyboard
    printf("\n Sum of char = %d\n", jumkar);

    return 0;

Show Integer to Hexadecimal,Octal, and Where it's Memory Location.

Thursday, October 8, 2009

This is just want to show You the reader, how to show integer to hexadecimal and octal. And also show the memory location.

/* menampilkan desimal dan heksadesimal */

int main(void){
    int X;

    printf("Please insert integer number: ");
    scanf("%d", &X);

    printf("%d is %#x in hexadecimal and %o in octal.\n", X, X, X );
    printf("%d is in memory address %p", X, &X);

    return 0;

Using Array and Functions

Wednesday, October 7, 2009

This is the example:


void tulisan1(void);
void tulisan2(void);

int main(void){

void tulisan1(void){
    char array1[] =

void tulisan2(void){
    char array2[] = "Tampilkan";
    printf("%s\n", array2);

Get Input String From Keyboard

Saturday, October 3, 2009

Now, we'll show how to get input string from keyboard using C. This is the example:

/* Example using gets() and scanf() to input string.

int main(void){
    char name[15];

    printf("Insert Your name please: ");
    // or scanf("%s", name);

    printf("Halo, %s. Happy enjoying C. \n", name);

Print Hello World Using Assembler

Friday, October 2, 2009

I use MASM and RadAsm-IDE for learning assembler.
This is the example, print "hello world":

[Basic]Using Array

Thursday, October 1, 2009

Now we'll try to using array to find rate of input values. This is the code:

*/ Oct 1, 2009 */

#include <stdio.h>
#define MAKS 5

int main(void){

    int i;
    float total = 0, rata;
    float nilai_tes[MAKS];   /* deklarasi array */

    for(i=0; i<MAKS; i++){
        printf("Nilai tes ke-%d : ", i+1);
        scanf("%f", &nilai_tes[i]);

        /* hitung jumlah total nilai */
        total = total + nilai_tes[i];
    rata = total / MAKS;

    /* cetak nilai rata2 */
    printf("\nNilai rata-rata = %g\n", rata);

    return 0;

And, this is the example of its execution:

Copyright © Welcome