In your opinion, what is the best method for validating a user input string.
For example , to make sure that the user input 7 digits as opposed to letters or a mix of the two.
Should I use a loop...
Type: Posts; User: daynorb
In your opinion, what is the best method for validating a user input string.
For example , to make sure that the user input 7 digits as opposed to letters or a mix of the two.
Should I use a loop...
Thanks for the help!
The issue was indeed the linefeed in the gets() value, which was removed using the above method.
Are you referring to this?
char *newline = strchr(FileString, ' ');
if ( newline != NULL )
{
*newline = '\0';
...
What might be a way to fix that? I read somewhere about a Replace function that worked like this:
StudentSearch.Replace("\n\r","");
but this makes absolutely no sense to me and it didn't work...
line 46 " scanf("%s", n); " was just to prevent the program crashing in an endless loop and so I could see the progress of the file pointer.
Hello again so soon,
Still writing for a file based database, but now I'm trying to search for key strings to retrieve specific lines of data.
My problem is that even though I can see that my...
Great thanks to all of you, it's working quite nicely now!
Do you mean something like this?
char AddStudent()
{
FILE *fptr;
struct Students
Unfortunately this didn't really solve the problem.
The main issue is that line
printf("Please enter the first name of the student: ");
fgets(GNG1106[0].FirstName, SIZE, stdin);
Thanks! I'll give this a try :)
sorry, quick-fix. In lines 34 and 38 I changed fptr to stdin. However, those first two commands are still sticking together and not allowing me to input the First Name.
Any suggestions?
Hey there,
In this component of a program I'm working on, the first four commands in my else statement are sticking together without letting me input the information I'm asking for. I had the same...
Thanks for the tip.
So I switched to fgets()
else
{
printf("File was opened");
Hi everyone,
I'm working on a program for developing files for student marks. My issue is in the else statement. What's happening is that it prints the prompt for the First Name but then prints...
You're beautiful and I'm an idiot! Thank you so much!
Braydon
This problem has been occurring for a couple days, but only for this program. My other programs still works fine. I am still VERY new to programming, so this may just be problems with syntax, so I...
Hey everyone,
So, I'm in the middle of writing a program in C focusing on the use of random numbers, specifically their applications to dice and guessing games. However, every time I run my...