Question: I've been working on a C programming assignment and it is supposed to read the contents of two .txt files and write them onto a

I've been working on a C programming assignment and it is supposed to read the contents of two .txt files and write them onto a new .txt file. My program is able to perform successfully, but I have a problem with how the new .txt file is sorted. I'd would like to have the usernames aligned in one column and the passwords aligned in another column, my problem is that the content displayed on the two columns are not showing up right next to each other in rows. How do I fix this problem?

I've been working on a C programming assignment and it is supposedto read the contents of two .txt files and write them onto

int main() // Open the existing usernames.txt file in order to read the data FILE *fr1= fopen( "usernames.txt", "r" ); // Open the existing passwords.txt file in order to read the data FILE *fr2= fopen( "passwords . txt", "r" ); // Open a new file named usernamesPasswords.txt to write data FILE *fw = fopen( "usernamesPasswords.txt", "w" ); // Declares a string of size 208 char s11300], s2300 /I Verify if usernames.txt could open or not if ( fr1 = NULL 11 fw NULL ) printf Could not open file usernames.txt" if ( fgets( s1, 300, fr! ) != NULL ) printf( "Could open file usernames.txt ") // Verify if passwords.txt could open or not if ( fr2 = NULL 11 fw NULL ) printf( "Could not open file passwords.txt" if ( fgets( S2, 300, fr2 ) != NULL ) printf( "Could open file passwords.txt " // While loop gets the contents found in the usernames.txt and passwords.txt files while( fgets( s1, 300, frl) && fgets( s2, 300, fr2)) The contents found in the files usernames.txt and password.txt wi11 be written into a new file named usernamesPasswords.txt / fprintf( fw, "%s\t\t\t\t%s ", s1, s2 ); / Close all files fclose( fri ); fclose( fr2); fclose( fw); return 8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!