'How to read line from file with different types in c
struct bank{
struct branch *branches;
struct operation_type *optypes;};
struct operation_type{
char optname[100];
float commission;
int optnum;
struct operation_type *nextopt;};
void readOperationTypes(char inputFile[100], struct bank* bank){
FILE *file = fopen(inputFile,"r");
if(file != NULL){
while(fscanf(file, "%s %f", bank->optypes->optname, &bank->optypes->commission) == 1)
bank->optypes->nextopt = bank->optypes;
}
else{
printf("\nThe file you looking for doesn't exist.");
}}
I'm trying to scan my opt.txt file which context like this
- EFT 15.6
- Withdraw 0.9
they don't have numbers at start just text and float. I'm trying to scan a txt file like this and getting nothing in while loop. How can i fix that ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
