Program Help for Newbie 
Author Message
 Program Help for Newbie

I need to write a program that reads in phonenumbers(without dashes) from 2
files, and then "weed" out the doubles, and put all the numbers into file3, so
somebody won't be called twice. After the prog is finished, it will close the
files, and then the user can open the file3 for the numbers.  This is what i
have so far, but i can't seem to write the code for the last part of psuecode I
have. Please help.

#include<stdio.h>

int main()
{
        int num1,num2;
        FILE *file1, *file2, *file3;
        file1=fopen("a:phone1.dat","r");
if (file1 == NULL)
{
        printf("Error opening phone1.dat!\n");
        exit;

Quote:
}

file2 = fopen ("a:phone2.dat","r");
if (file2 == NULL)
{
        printf("Error opening phone2.dat!\n");
        exit;
Quote:
}

file3 = fopen ("phone3.dat","w");
if (file3 == NULL)
{
        printf("Error opening output file phone3.dat!\n");
        exit;

Quote:
}

read record from file1,file2    
while(file1 !=eof && file2 !=eof)
if(num1=num2)
                write num1 to file 3
                throw num2 to out????
                read next record from file1,file2
else if(num1< num2)
        write num1 to file 3
        read next record from file 1
else if(num1>num2)
        write num2 to file 3
read RECORD FROM FILE2
end while

fscanf(file1,"  "  &  );
fscanf(file2,"  "  &  );
while(file1 !=eof && file2 !=eof)
if(num1=num2)
--



Fri, 19 Apr 2002 03:00:00 GMT  
 Program Help for Newbie
I'm writing a program in C, that reads in phone numbers(no dashes) from two
files, and "weed"s out the doubles and puts the numbers in file3. So the user
wont' call the phone numbers twice. After the program is done it will close all
files, and the user can open file 3 for the numbers. I'm having problems of
doing the code for the pseucode(in bold) on the bottom. Underneath the
psuecode, is what i have so far for the code for it. Please help..

#include<stdio.h>

int main()
{
        int num1,num2;
        FILE *file1, *file2, *file3;
        file1=fopen("a:phone1.dat","r");
if (file1 == NULL)
{
        printf("Error opening phone1.dat!\n");
        exit;

Quote:
}

file2 = fopen ("a:phone2.dat","r");
if (file2 == NULL)
{
        printf("Error opening phone2.dat!\n");
        exit;
Quote:
}

file3 = fopen ("phone3.dat","w");
if (file3 == NULL)
{
        printf("Error opening output file phone3.dat!\n");
        exit;

Quote:
}

read record from file1,file2    
while(file1 !=eof && file2 !=eof)
if(num1=num2)
                write num1 to file 3
                throw num2 to out????
                read next record from file1,file2
else if(num1< num2)
        write num1 to file 3
        read next record from file 1
else if(num1>num2)
        write num2 to file 3
read RECORD FROM FILE2
end while

fscanf(file1,"  "  &  );
fscanf(file2,"  "  &  );
while(file1 !=eof && file2 !=eof)
if(num1=num2)

--



Fri, 19 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ***Newbie Needs Help With Functions Program ***

2. I need help with a program newbie :)

3. ***Newbie Needs Help With Functions Program ***

4. newbie help with sockets programming...

5. Help for C newbie with simple stat() program.

6. Semi-newbie programmer seeking help with comm program

7. ***COMPLETE PROGRAMMING NEWBIE: PLEASE HELP!!!***

8. c newbie needs help with programs!!

9. Newbie: Program Design help

10. Newbie at programming needs help

11. Newbie: Help with multiple files program

12. NEWBIE: Help on Microsoft programming

 

 
Powered by phpBB® Forum Software