Hi!, i'm writing from Argentina. I need your help!
I'm doing a project for the university and i have to make a Restaurant management. Well that´s not the problem. I have to log into the software, so i need to read from a file that have the user and password. So when the user tries to log in, the software have to checks into my txt file of users. In case the user puts the correct username and password he´ll be able to step to the general menu else the software doesn´t allow him.
Can yo help me??


Yes, we can help, but not without knowing the details of the text file. Exactly what is in the file and how is it formatted. Post an example of the file.

Once you know that, all you have to do it open the file with ifstream object then read sequentially until you find the record you want. Can't tell you much more without knowing the details of the file.

/* My file layout (nombre.txt)



I think i solved it. when the user put his username and password i sum them in a major chain with a ";" in the middle as i have in mi file (nombre.txt), then i compare using strcmp the chain i get from the file with the one the user enters. if both are equal, the login is correct else the user entered an incorrect login.

#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <fstream>
#define tm 20
using namespace std;

void SumarCadenas(char [],char []);
int Long(char text[]);
void Vaciar(char [],int); /*Vacía un arreglo*/

int main() {
   int i,k;
   char sep[tm]={';','\0'};
   char usuario[tm];
   char contrase[tm];
   char SumaCadenas[tm+tm];
   char CadenaArchivo[tm+tm];
   cout << "Usuario: ";
   cout << "Contraseña: ";
  cout << SumaCadenas;
   ifstream fe("nombre.txt");
    while(!fe.eof()) {
        cout <<"\n**** LOGIN INCORRECTO ****";
   return 0;

void SumarCadenas(char text1[],char text2[]){
int i,n1,n2;
int Long(char text[]){
int n;
return n;
void Vaciar(char txt[],int n){
int i;

P.S: Excuse me if my english is not well written! i'm doing my best! heheh

Thanks for your answer

>>P.S: Excuse me if my english is not well written! i'm doing my best! heheh
You did great :)

why don't you use the standard C function strlen() instead of your function Long()?

Since this is a c++ program why don't you use std::string instead of those char arrays?

i'm just starting in C++ and i´m reading all over the internet examples. My professor gave me a very difficult work! it´s driving me crazy!
As i´ve learnt ANSI C, manage with classes and objets confuse me!
Thanks for your help!
By the way, where are you from?

By the way, where are you from?

See the line just above my post count. If you are not familar with USA geography, then get a map and look near the center of the nation.

Arizona? I´ve heard of it. But i don´t know USA, so it´s the same! hehehe
don't you know Argentina?

I live in Illinois. Go to google maps. You will find Arizona near the bottom left of USA, next to California on the west (left) and Mexico on the south. Illinois (abbreviated IL on the map) is more towards the center of the map, both horizontally and vertically. Illinois is about 1,500 miles from Arizona.

>>don't you know Argentina?
what part of Texas, USA is that in? (LOL that's supposed to be a tired old Texas joke).

This article has been dead for over six months. Start a new discussion instead.