Thread: Frustrated

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    208

    Frustrated

    ok I haven't programed in a while and I never had much luck with the string.h library so this is prolly the dumbest thing ever but here it goes I am making a simple input program for a logic prgram I am going to be making later and I keep getting incompatible type and invalid conversion from int errors and I have no idea what I did wrong most of the errors are in the strcmp functions. Thanx

    Code:
    #include <iostream.h>
    #include <stdlib.h>
    #include <string.h>
    #include <fstream.h>
    char name[9];
    char filename[9];
    
    int input();
    int main()
    { int yesno;
      cout<<"Logic.";
      cout<<"Please enter your username (less then 4 letters):";
      strcpy(filename,name);
      filename=strncat(filename,".txt", 4);
      ifstream file(filename);
      if (!file)
      {file.close();
       cout<<"I'm sorry but you either typed your name in wrong or haven't used the program before.\n";
       cout<<"Would you like me to create a New account? (y/n): ";
       cin>>yesno;
      if (strcmp (yesno, "n") != 0 || strcmp (yesno, "N") != 0)
       {cout<<"ok then thank you;";
        system("PAUSE");
        return 0;
       }
       if (strcmp (yesno, "y") != 0 || strcmp (yesno, "Y") != 0)
       {ofstream a_file("example.txt");
        cout<<"\n Your File Has been successfully created!";
        input();
       }
    
          return 0;
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    cout<<"Logic.";
    cout<<"Please enter your username (less then 4 letters):";
    strcpy(filename,name);
    Shouldn't you actually prompt for the name there? Or rather, shouldn't you actually read input?

    Quzah.
    Last edited by quzah; 10-07-2002 at 03:01 PM.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. frustrated bout char array
    By royuco77 in forum C++ Programming
    Replies: 2
    Last Post: 07-11-2005, 09:10 AM
  2. Getting frustrated
    By kippwinger in forum C++ Programming
    Replies: 17
    Last Post: 07-02-2003, 03:55 PM
  3. A Bit Frustrated....
    By DirX in forum C++ Programming
    Replies: 3
    Last Post: 04-14-2003, 10:29 PM
  4. so confused and frustrated
    By ct26torr in forum C Programming
    Replies: 2
    Last Post: 02-13-2003, 10:40 PM
  5. so frustrated!!!!
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 11-28-2001, 06:44 PM