سفارش تبلیغ
جنبش وبلاگی دفاع از مقدسات
آموزش برنامه نویسی مبتدی C - آموزش برنامه نویسی مبتدی برای دانشجویان


22/6/88
12:46 صبح

آموزش برنامه نویسی مبتدی C

بدست hsanali lotfi در دسته

<!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; font-size:14.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:612.0pt 792.0pt; margin:45.0pt 45.0pt 72.0pt 45.0pt; border-top:ridge; border-left:ridge; border-bottom:groove; border-right:groove; border-color:windowtext; border-width:6.0pt; padding:24.0pt 24.0pt 24.0pt 24.0pt;} div.Section1 {page:Section1;} -->

 


مثال 31) برنامه ای بنویسید که مشخصا ت پرسنل یک شرکت را گرفته سپس آنها را در فایلی نگهداری کند سپس از آن لیست حقوق کارمندان را محاسبه و چاپ کند .


# include <stdio.h>                             # include <conio.h>


# include <stdlib.h>                             # include <string.h>


int main( )


{


File *f;


Char numstr[10];


Int I,salary;


Struct em


           {


               Char name[10];


                Int hp;


                Int h;


           }


Emp;


Clrscr( );


F=fopen("employ.dat" ,"wb+");


If (!f)


{


Printf("can not open fill");


Exit 0;


}


Printf("name hour pay , hour");


While(y)


{


Gets(em.name); = scanf("%d",&emp,name);


If(!emp.name);


Break;


Gets(num str );


Emp.hp=atio(numstr);


Gets(num str );


Emp.h=atio(num str);


Fwrite(&emp,sizeof(structem),I,f);


{


   Rewrute(f);


    Clrscr ( );


 Puts(name salary):
FREAD(&emp,size of (struct em),I,f);


While (!feof(f))


{


Puts(ep.name);


Printf(%d \n memp.hp*emp.h);


Fread(&emp , size of (structem), I,f );


}


Close (f);


Getch( );


Return 0;


}