Sponsored Content
Top Forums Programming does any one know how to solve? Post 302227181 by mlhazan on Wednesday 20th of August 2008 06:42:16 PM
Old 08-20-2008
Do you know why for loop does not work?
Code:
#include <stdio.h>
#include <stdlib.h>

struct date {
    int month;
    int day;
    int year;
    };
struct empRec{
    char name[25];
    char room[10];
    int jobLevel;
    struct date startDate;
    };

int main(){
    FILE *data;
    static struct empRec employee[1000]={
                {"Peter North","4B-208",35400,{10,11,1983}},
                {"John Musa","2B-118",25400,{07,10,1993}},
                {"Paula Jeminova","1A-506",18700,{02,1,1990}},
                {"Patricia Silver","6C-123",52100,{14,21,2000}},
                {"Robert mill","4D-318",42100,{01,19,2008}},
            };

        struct empRec employee2;

    if((data=fopen("database","w+"))==NULL){
                fprintf(stderr,"Can't Create database\n");
                exit(1);
                }
    if(fwrite(&employee,sizeof(struct empRec),1,data)!=1){
                fprintf(stderr,"WRITE ERROR\n");
                exit(1);
                }

    rewind(data);
    fread(&employee,sizeof(struct empRec),1,data);
    int n;
    for (n = 0; n < employee.length; n++) { 
    printf("%s %s %d %d %d %d\n", employee[n].name, employee[n].room, employee[n].jobLevel, employee[n].startDate.month, employee[n].startDate.day, employee[n].startDate.year);
    
    }    
    fclose(data);
    printf("Created database\n");
    exit(0);
}

 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to solve this

I have to write an script for.. CUST: 123 trans: some contents CUST: 1234 trans: some contents Now wat i have to do is this: CUST:123 akash trans: some contents CUST:1234 akash1 trans: I have been able to add... (3 Replies)
Discussion started by: akashag22
3 Replies

2. Shell Programming and Scripting

Can somebody solve this please

I have to find the files older than 200 days from a path and copy them to some other directory with the current date stamp attached to it. i have written like follows: #!/bin/ksh DSTAMP=$(date +"%y%m%d%H%M") rm $CA_OUT_PATH/ftp_logs/temp touch $CA_OUT_PATH/ftp_logs/temp chmod 777... (1 Reply)
Discussion started by: sreenusola
1 Replies

3. UNIX for Advanced & Expert Users

Can somebody solve this

I have to find the files older than 200 days from a path and copy them to some other directory with the current date stamp attached to it. i have written like follows: #!/bin/ksh DSTAMP=$(date +"%y%m%d%H%M") rm $CA_OUT_PATH/ftp_logs/temp touch $CA_OUT_PATH/ftp_logs/temp chmod 777... (1 Reply)
Discussion started by: sreenusola
1 Replies

4. UNIX for Dummies Questions & Answers

Can somebody solve this

I have to find the files older than 200 days from a path and copy them to some other directory with the current date stamp attached to it. i have written like follows: #!/bin/ksh DSTAMP=$(date +"%y%m%d%H%M") rm $CA_OUT_PATH/ftp_logs/temp touch $CA_OUT_PATH/ftp_logs/temp chmod 777... (13 Replies)
Discussion started by: sreenusola
13 Replies

5. Homework & Coursework Questions

help me to solve it thank you

i thought about to use the commands : wc and sort and mybe more .. i need to write a bash script that recive a list of varuables kaka pele ronaldo beckham zidane messi rivaldo gerrard platini i need the program to print the longest word of the list. word in the output appears on a separate... (1 Reply)
Discussion started by: yairpg
1 Replies

6. UNIX Desktop Questions & Answers

please help me to solve it

i thought about to use the commands : wc and sort cut and mybe more .. i need to write a bash script that recive a list of varuables kaka pele ronaldo beckham zidane messi rivaldo gerrard platini i need the program to print the longest word of the list. word in the output appears on a... (0 Replies)
Discussion started by: yairpg
0 Replies
LedgerSMB::DBObject::Employee(3pm)			User Contributed Perl Documentation			LedgerSMB::DBObject::Employee(3pm)

NAME
LedgerSMB::DBObject::Employee - LedgerSMB class for managing Employees SYOPSIS
This module creates object instances based on LedgerSMB's in-database ORM. METHODS
The following method is static: new ($LedgerSMB object); save Saves an employee. Inputs required entity_id May not be undef start_date end_date dob date may not be undef role Not the database role. Either manager or user ssn sales manager_id employee_number search Returns a list of employees matching set criteria: employeenumber (exact match) startdate_from (start of date range) startdate_to (end of date range) first_name (partial match) middle_name (partial match) last_name (partial match) notes (partial match) Undef values match all values. set_entity_class Sets the entity class to 3. get_managers Retrieves a set of managers and attaches to $self->{all_managers} save_location Saves the location data for the contact. Inputs are standard location inputs (line_one, line_two, etc) save_contact Saves contact information. Inputs are standard contact inputs: entity_id contact_class contact description save_bank_account Saves a bank account to an employee. Standard inputs (entity_id, iban, bic) get_metadata() This retrieves various information vor building the user interface. Among other things, it sets the following properties: $self->{ar_ap_acc_list} = qw(list of ar or ap accounts) $self->{cash_acc_list} = qw(list of cash accounts) get Returns the employee record with all the inputs required for "save" populated. Also populates: locations List of location info contacts List of contact info notes List of notes bank account List of bank accounts save_notes Saves a note to an employee entity. Standard inputs (note, subject, entity_id) delete_contact required request variables: contact_class_id: int id of contact class contact: text of contact information person_id: int of entity_credit_account.id, preferred value delete_location Deletes a record from the location side. Required request variables: location_id location_class_id person_id Returns true if a record was deleted. False otherwise. delete_bank_account Deletes a bank account Requires: entity_id bank_account_id Returns true if a record was deleted, false otherwise. get_user_info Attaches the user_id and username to the employee object. If the user does not have manage_users powers, this will simply return false Copyright (C) 2007, The LedgerSMB core team. This file is licensed under the Gnu General Public License version 2, or at your option any later version. A copy of the license should have been included with your software. perl v5.14.2 2012-03-10 LedgerSMB::DBObject::Employee(3pm)
All times are GMT -4. The time now is 06:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy