Blizzardo1 icon

CardCreator.c

Blizzardo1 | PRO | 05/06/18 06:54:00 PM UTC | 0 ⭐ | 766 👁️ | Never ⏰ | []
C |

1.09 KB

|

None

|

0 👍

/

0 👎

#include <stdio.h>
#include <stdlib.h>
 
FILE *_file;
char name[30];
char email[30];
char telephone[12];
char city[30];
int count;
 
void replstr(char s[], char chr, char newchar) {
    int i = 0;
    while(s[i] != '\0') {
        if(s[i] == chr)
            s[i] = newchar;
        i++;
    }
}
 
int main (void) {
    _file = fopen("X:\\Your\\File\\Path\\Here.txt", "w");
    if(_file == NULL){
        printf("ERROR: Failed to open File for writing!");
        return -1;
    }
 
    printf("How many cards do you want to create? ");
 
    scanf("%d", &count);
    printf("Creating %d cards\r\n", count);
    
    for(int i = 0; i < count; i++) {
        printf("[%d] Name, Telephone, Email, City: ", i + 1);
        scanf("%s %s %s %s", name, telephone, email, city);
        replstr(name, '_', ' ');
        replstr(name, '/', ',');
        replstr(city, '_', ' ');
        replstr(city, '/', ',');
        
        fprintf(_file, "%s, %s, %s, %s\r\n", name, telephone, email, city);
    }
 
    printf ("Done! Closing out now!");
 
    fclose(_file);
 
    return 0;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎