What's New-Given Below
technicalsymposium
technicalsymposium
technicalsymposium

College Lab Codings/Project Codings-Download


DataStructure-Program to allocate memory dynamically.

#include <stdio.h>
#include <conio.h>
#include <alloc.h>
#include <string.h>
void main( )
{
char *name[5] ;
char str[20] ;
int i ;
clrscr( ) ;
for ( i = 0 ; i < 5 ; i++ )
{
printf ( "Enter a String: " ) ;
gets ( str ) ;
name[i] = ( char * ) malloc ( strlen ( str ) + 1 ) ;
strcpy ( name[i], str ) ;
}
printf ( "\nThe strings are:" ) ;
for ( i = 0 ; i < 5 ; i++ )
printf ( "\n%s", name[i] ) ;
for ( i = 0 ; i < 5 ; i++ )
free ( name[i] ) ;
getch( ) ;
}

Hosting by Yahoo!

About-Us    Contact-Us    Site-map

©copyright 2009 All rights are reserved to technicalsymposium.com