You are on page 1of 2

----------------Shell programing to list all directory files to a directory?

-------------------Answer:
Improve

for i in * do if [ -d $i ]; then echo $i directory >> /tmp/directories fi done

add a new record in a file

Posted 09 October 2009 - 06:56 AM

we have already existance 7 employee in a file named employee.txt.the problem is , we cannot add a record of a new employee. it appears a blank screen when we run the program. #include <stdio.h> int main() { char name[10][244]; char icnumber[10][244]; char phonenumber[10][244]; int salary[10]; int i, count=0; FILE * employee; employee=fopen("employee.txt","a"); fprintf(employee,"\n%s %s %s %d",name,icnumber,phonenumber,salary );

for (i=0; i<count; i++) { printf("\n %d. %s",i, name[i]); }

printf("\n To add record press enter :");

printf("\n enter your name : "); scanf("%s" , name); printf("\n enter your icnumber : "); scanf("%s" , icnumber); printf("\n enter your phonenumber : "); scanf("%s" , phonenumber); printf("\n enter your salary : "); scanf("%d" , &salary);

return 0; }

You might also like