Sir? Builtin Function Help
-
Hi, How are you?...i hope you are doing fine... i want to ask is there any built in function to get on exact line in a file? Like: FILE DATA: 1)Start 2)Mid 3)Username 4)END i want to get the pointer of file handler on 3 so that i can read that specific line.... or Can we use Seekg.(); function in this case? Kindly help please
-
Hi, How are you?...i hope you are doing fine... i want to ask is there any built in function to get on exact line in a file? Like: FILE DATA: 1)Start 2)Mid 3)Username 4)END i want to get the pointer of file handler on 3 so that i can read that specific line.... or Can we use Seekg.(); function in this case? Kindly help please
I don't know of such a function. If each line ends in an
'\n'
, you can usestd::getline
to read each one and count up to the line you want.seekg
moves by a specified number of characters, so it won't help unless lines are padded to a fixed length.Robust Services Core | Software Techniques for Lemmings | Articles
-
I don't know of such a function. If each line ends in an
'\n'
, you can usestd::getline
to read each one and count up to the line you want.seekg
moves by a specified number of characters, so it won't help unless lines are padded to a fixed length.Robust Services Core | Software Techniques for Lemmings | Articles
#include
#include
using namespace std;void Signup(int UserCheck)
{
char Firstname[30] = { 0 }, Lastname[30] = { 0 }, Username[11] = { 0 }, Password[11] = { 0 }, ConfirmPassword[11] = { 0 }, File[50] = { 0 }, CNIC[16] = { 0 };
cout << "Sign Up:\nFirst Name: "; cin >> Firstname;
cout << "Last Name: "; cin >> Lastname;
ifstream Read;
while(true)
{
cout << "Uername (eight to ten letters only): "; cin >> Username;
if(UserCheck == 1)
{
strcat(File, "S"); strcat(File, Username); strcat(File, ".txt");
}
else if(UserCheck == 2)
{
strcat(File, "B"); strcat(File, Username); strcat(File, ".txt");
}
Read.open(File);
if((strlen(Username) >= 8 && strlen(Username) <= 10) && (!(Read.is_open())))
{
Read.close();
break;
}
else
{
cout << "\nUsername should be unique and contain 8-10 letters only.\n";
}
}
cout << "CNIC:";
for(int i = 0; i < 15; i++)
{
if(i == 5 || i == 13)
{
cout << "-"; CNIC[i] = '-';
}
else
{
cin >> CNIC[i];
}} while(true) { cout << "Password: "; cin >> Password; if(strlen(Password) >= 8 && strlen(Password) <= 10) { while(true) { cout << "Confirm Password: "; cin >> ConfirmPassword; if(strcmp(Password, ConfirmPassword) == 0) { break; } else { cout << "\\nPassword did not matched.\\n"; } } break; } else { cout << "\\nPassword is not acceptable, it should have only 8-10 letters.\\n"; } } ofstream Write(File); Write << Firstname << endl; Write << Lastname << endl; Write << Username << endl; Write << CNIC << endl; Write << Password << endl; Write.close();
}
//void Login(int UserCheck)
//{
// char File[50] = { 0 }, Username[11] = { 0 }, Password[11] = { 0 }, CheckPassword[11] = { 0 };
// ifstream Read;
// while(true)
// {
// cout << "Uername (eight to ten letters only): "; cin >> Username;
// if(UserCheck == 1)
// {
// strcat(File, "S"); strcat(File, Username); strcat(File, ".txt");
// }
// else if(UserCheck == 2)
// {
// strcat(File, "B"); strcat(File, Username); strcat(File, ".txt");
// }
// Read.open(File);
// if((strlen(Username) >= 8 && strlen(Username) <= 10) && (Read.is_open()))
// {
// break;
// }
// else
// {
// cout << "\nInvalid Username.\n";
// }
// }
// int Line = 1, i = 0; char temp = 0;
// while(Line != 5);
// {
// Read>>temp;
// cout << temp;
// if(temp == '\n')
// {
// Line++;
// }
// i++;
// } -
Hi, How are you?...i hope you are doing fine... i want to ask is there any built in function to get on exact line in a file? Like: FILE DATA: 1)Start 2)Mid 3)Username 4)END i want to get the pointer of file handler on 3 so that i can read that specific line.... or Can we use Seekg.(); function in this case? Kindly help please
-
Hi, How are you?...i hope you are doing fine... i want to ask is there any built in function to get on exact line in a file? Like: FILE DATA: 1)Start 2)Mid 3)Username 4)END i want to get the pointer of file handler on 3 so that i can read that specific line.... or Can we use Seekg.(); function in this case? Kindly help please
-
but i want to privately message you dont want leak my code please check the inbox kindly ... Thank you
-
but i want to privately message you dont want leak my code please check the inbox kindly ... Thank you
-
but i want to privately message you dont want leak my code please check the inbox kindly ... Thank you
Oh, this explains why I got an email that contained code but couldn't find the same message on this board. Sorry, I don't do code inspections. If you don't know how to use a debugger, you need to learn now. The days when I wrote code with very few errors are gone. I wouldn't be able to do anything without a debugger now. They're so much better and easier to use than they were 40 years ago that I just focus on the design and then use the debugger to fix the details that I got wrong. :-D
Robust Services Core | Software Techniques for Lemmings | Articles
-
Oh, this explains why I got an email that contained code but couldn't find the same message on this board. Sorry, I don't do code inspections. If you don't know how to use a debugger, you need to learn now. The days when I wrote code with very few errors are gone. I wouldn't be able to do anything without a debugger now. They're so much better and easier to use than they were 40 years ago that I just focus on the design and then use the debugger to fix the details that I got wrong. :-D
Robust Services Core | Software Techniques for Lemmings | Articles
Okay may be i disturbed everyone here for nothing... I'm really sorry for stupid questions. I do actually know how to debug you sir when you get stuck only then you ask for help... but that debugger get the job done after 7 hours :| ... and Richard's steps may be helpful but it is very difficult for me to understand it you know... Anyways Thank you for your help, i appreciate your help ;)
-
but i want to privately message you dont want leak my code please check the inbox kindly ... Thank you
If you can't write a function to search for a specific character in a text file, ('\n'), counting how many times you see that character, your code isn't worth hiding.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak