[ create a new paste ] login | about

Link: http://codepad.org/Pp4lu3dp    [ raw code | output | fork ]

kamarakay2000 - C, pasted on Jul 19:
#include <stdio.h>
#include <stdlib.h>
int main()
{ 
    struct stats{
        int account;
        float balance;
        struct stats *next;
    };
    struct stats *first;
    int a = 1;
    first = (struct stats *)malloc(sizeof(struct stats));
    if(first == NULL)
    {
        puts("Memory error");
        return(1);
    }
    first -> account = a;
    printf("Account %05d, enter the balance: $", first -> account);
    scanf("%f", &first -> balance);
    first -> next = (struct stats *) malloc(sizeof(struct stats));
    printf("Account %05d\tBalance: %.2f\n", first -> account,first -> balance);
    if(first -> next == NULL)
    {
        puts("Memiry errir");
    }
    return(1);
}


Output:
1
Account 00001, enter the balance: $Account 00001	Balance: -0.00


Create a new paste based on this one


Comments: