I've tested the code and the error seems to be coming from the second scanf()
scanf("%s", password);
I've commented the entire if statement out testing what is working and what isn't I've also tested to see if strcmp() was working and it was. I don't understand why I'm getting a segmentation fault on that scanf()
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include "Admin.h"
//#include "customer.h"
int main(int argc, char *argv[])
{
typedef char * String;
String AdminUser = "Admin";
String AdminPW = "Admin";
String username, password;
printf("Welcome to Online Banking/ATM System\n");
printf("====================================\n\n\n");
printf("Enter your Customer/Admin ID: ");
scanf("%s", username);
if (strcmp(username, AdminUser) == 0) {
printf("Enter your Customer/Admin Password: ");
scanf("%s", password);
if (strcmp(password, AdminPW) == 0) {
while(1){
break;
}
}
}
}
Also on a side note, if anyone could explain to me how to read and write files it would be great. I understand the basics of opening and closing a file and also reading and writing, but specifically what I need to know is how to write information into a file in such a way that I can refer back to it and pick pieces of information from it. EX:There's a list of people's banking information within a text file, I specifically want to see customer ID 12345. How can I do that, how can I edit it, and how can I delete it.
I'll probably figure it out eventually but help would be greatly appreciated!