Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include #include #include #include #include using namespace std; char *substring(size_t start, size_t finish, const char *src, char *merge, size_t size) { int

#include #include #include #include #include #include #include #include using namespace std; char *substring(size_t start, size_t finish, const char *src, char *merge, size_t size) { int count = finish - start; if ( count >= --size ) { count = size; } sprintf(merge, "%.*s", count, src + start); return merge; } int main() { char c[20] = " "; /* declare a char array */ char c2[20]= " "; /* declare a char array */ FILE *file, *file2, *file3; /* declare a FILE pointers */ file = fopen("username.txt", "r"); file2 = fopen("password.txt", "r"); file3 = fopen("usernamesPasswords.txt", "w"); /* open a text file for reading */ if(file==NULL) { printf("Error: can't open username file. "); return 1; } else if(file2==NULL) { printf("Error: can't open password file. "); return 1; } else if(file3==NULL) { printf("Error: can't open usernamesPasswords file. "); return 1; } else { char * p; while(fgets(c2, 200, file2) != NULL && fgets(c, 200, file) != NULL) { /* keep looping until NULL pointer... */ p = strchr(c, ' '); if (p) { *p = '\0'; } p = strchr(c2, ' '); if (p) { *p = '\0'; } fprintf(file3, "%s %s ",c, c2); } char choice,ch; printf("File Username Merged With File Password... "); printf("Do You Want to Display File Contents "); scanf("%c",&choice); fseek(file3, 0, SEEK_SET); // Set the file pointer to start of file printf("The Contents of usernamePasswords file is "); if (choice == 'Y' || choice == 'y') { file3 = fopen("usernamesPasswords.txt", "r"); while(1) { ch = fgetc(file3); if( feof(file3) ) { break; } printf("%c", ch); }

} else { printf("Program Closing "); }

fclose(file); fclose(file2); fclose(file3); return 0; } }

Can anyone correct this program i cannt run it

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago

Question

What is loss of bone density and strength as ?

Answered: 1 week ago