main() { employee *e; int i,n; char name[32]; printf("\nEnter number of Employees : "); scanf("%d",&n); e=(employee*)malloc(n*sizeof(employee)); printf("\nEnter Details\n"); for(i=0;i<n;i++) { printf("\nEnter details for Employee %d",i+1); printf("\nName : "); scanf(" %[^\n]",e[i].name); printf("\nEmployee No. : "); scanf("%d",&e[i].empNo); printf("\nPhone No. : "); scanf("%Ld",&e[i].phoneNo); } printf("\nEntered Details\nS.No\tName\tEmp.No\tPhone No.\n"); for(i=0;i<n;i++) printf("%d\t%s\t%d\t%Ld\n",i+1,e[i].name,e[i].empNo,e[i].phoneNo); printf("\nEnter a name : "); scanf(" %[^\n]",name); i=retIndex(e,n,name); if(i==-1) printf("\nEmployee Not Found.\n"); else printf("\nPhone Number of %s is : %Ld\n",name,e[i].phoneNo); free(e); }
// ----------------------------------------------------------------------------- // TAccPolGenericIDArrayAccessor::FindWithUniqueIDL // Look for a Generic ID from the array with Unique ID. // (other items were commented in a header). // ----------------------------------------------------------------------------- // EXPORT_C TInt TAccPolGenericIDArrayAccessor::FindWithUniqueIDL( const TAccPolGenericIDArray& aGenericIDArray, TInt aUnigueID ) { COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDArrayAccessor::FindWithUniqueIDL()" ); TInt retIndex( KErrNotFound ); TInt count( aGenericIDArray.Count() ); for ( TInt i( 0 ); i < count; ++i ) { if ( aGenericIDArray.GetGenericIDL( i ).UniqueID() == aUnigueID ) { retIndex = i; break; // from for loop } } COM_TRACE_1( "[AccFW: ACCPOLICY] TAccPolGenericIDArrayAccessor::FindWithUniqueIDL() - return %d", retIndex ); return retIndex; }
// ----------------------------------------------------------------------------- // TAccPolGenericIDArrayAccessor::FindWithDeviceAddressL // Look for a Generic ID from the array with Device Address. // (other items were commented in a header). // ----------------------------------------------------------------------------- // EXPORT_C TInt TAccPolGenericIDArrayAccessor::FindWithDeviceAddressL( const TAccPolGenericIDArray& aGenericIDArray, const TUint64& aDeviceAddress ) { COM_TRACE_( "[AccFW: ACCPOLICY] TAccPolGenericIDArrayAccessor::FindWithDeviceAddressL()" ); TInt retIndex( KErrNotFound ); TInt count( aGenericIDArray.Count() ); for ( TInt i( 0 ); i < count; ++i ) { if ( aGenericIDArray.GetGenericIDL( i ).DeviceAddress() == aDeviceAddress ) { retIndex = i; break; // from for loop } } COM_TRACE_1( "AccFW: [ACCPOLICY] TAccPolGenericIDArrayAccessor::FindWithDeviceAddressL() - return %d", retIndex ); return retIndex; }