473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

What is wrong? I can't add...

Ok Here is a problem, I got a imaginary database program that I need
to code, to add a patient I have function inser_patient. but when I
try to input the details it doesn't quite work the way I wanted it to.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

#define MAXPATIENTS 20

struct details {
int id;
char forename[20];
char initial;
char surname[20];
int day_of_entry;
int max_wait;
};

struct details patient[MAXPATIENTS];
int npatients = 0;

int insert_patient(int index, struct details newpatient);

int main (void) {
int Choice;
int id;
int loop = 1;
int n=0;
int error=0;
int limit;
int Qnum;

FILE * fptr; //Declares file pointer as "fptr"
fptr = fopen("queue.dat", "r"); //Opens queue.dat to fptr
//Reading
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){
n++;
}
fclose(fptr);
//Loop that continues the program
while(loop != 0){
//To keep program running
//Displaying Menu
printf("\n\n");
printf("%d \n",day_now());
printf("_________________________________________\ n");
printf("|-----------NHS Queue Control-----------|\n");
printf("| Create New Patient \t- Press 1\t|\n");
printf("| Delete Patient \t- Press 2\t|\n");
printf("| Find Patient \t\t- Press 3\t|\n");
printf("| List Queue \t\t- Press 4\t|\n");
printf("| Treate Next Patient \t- Press 5\t| \n");
printf("| Quit \t\t\t- Press 6\t|\n");
printf("|_______________________________________|\ n");
printf("Choice: ");
scanf("%d",&Choice);
printf("\n");
//Choice made, carrying out function
switch (Choice){
//New Patient
case 1:
limit = n;
if(limit < 21){
list_queue();
printf("\nPlease enter the following details\n");
printf("What Queue Number would you like to place this patient
to?\n");
scanf("%d", &Qnum);
printf("Patient ID: ");
scanf("%d", &patient[20].id);
printf("Forename: ");
scanf("%s", patient[20].forename);
printf("Middle Initial: ");
scanf("%c ", &patient[20].initial);
printf("Surname: ");
scanf("%s ", patient[20].surname);
printf("Maximum Waiting Time: ");
scanf("%d ", &patient[20].max_wait);
patient[20].day_of_entry = day_now();
error = insert_patient(Qnum, patient[20]);
if(error == -1){
printf("Error - Patient exists!\n");
}
else {
printf("\nPatient Inserted!\n");
}
}
else {
printf("Array is Full!\n");
}
break;
}
return 0;
}

//This is the add function
int insert_patient(int index, struct details newpatient) {
int i = 0;
int n = 0;
int y = find_patient_id(index) ;
int x;
int error;

FILE * fptr; //Declares file pointer as "fptr"
fptr = fopen("queue.dat", "r");
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){
n++;
}
fclose(fptr);

if(y == -1){
fptr = fopen("queue.dat", "w");
for(i=0;i<=index-2;i++){
fprintf(fptr,"%d ",patient[i].id);
fprintf(fptr,"%s ",patient[i].forename);
fprintf(fptr,"%c ",patient[i].initial);
fprintf(fptr,"%s ",patient[i].surname);
fprintf(fptr,"%d ",patient[i].day_of_entry);
fprintf(fptr,"%d \n",patient[i].max_wait);
}

fprintf(fptr,"%d ",patient[20].id);
fprintf(fptr,"%s ",patient[20].forename);
fprintf(fptr,"%c ",patient[20].initial);
fprintf(fptr,"%s ",patient[20].surname);
fprintf(fptr,"%d ",patient[20].day_of_entry);
fprintf(fptr,"%d \n",patient[20].max_wait);

for(x=index;x<=n+1;x++){
fprintf(fptr,"%d ",patient[x].id);
fprintf(fptr,"%s ",patient[x].forename);
fprintf(fptr,"%c ",patient[x].initial);
fprintf(fptr,"%s ",patient[x].surname);
fprintf(fptr,"%d ",patient[x].day_of_entry);
fprintf(fptr,"%d \n",patient[x].max_wait);
}
error = 0;
}
else if (y != 0){
error = -1;
}
fclose(fptr);
return error;
}

May 28 '07 #1
16 1744
On 28 May 2007 12:14:33 -0700, "ch****@gmail.com" <ch****@gmail.com>
wrote:
>Ok Here is a problem, I got a imaginary database program that I need
to code, to add a patient I have function inser_patient. but when I
try to input the details it doesn't quite work the way I wanted it to.
Are we supposed to guess what you are talking about? What did you
want? What actually happened?
>
Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

#define MAXPATIENTS 20

struct details {
int id;
char forename[20];
char initial;
char surname[20];
int day_of_entry;
int max_wait;
};

struct details patient[MAXPATIENTS];
int npatients = 0;

int insert_patient(int index, struct details newpatient);

int main (void) {
int Choice;
int id;
int loop = 1;
int n=0;
int error=0;
int limit;
int Qnum;

FILE * fptr; //Declares file pointer as "fptr"
fptr = fopen("queue.dat", "r"); //Opens queue.dat to fptr
You should verify that fopen succeeded.
> //Reading
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){
This is the wrong test. fscanf returns EOF only if no data was
converted. You should be proceeding only if the return value is 6.
> n++;
You never check for n overflowing the number of elements in your
array.
> }
fclose(fptr);
//Loop that continues the program
while(loop != 0){
//To keep program running
//Displaying Menu
printf("\n\n");
printf("%d \n",day_now());
printf("_________________________________________\ n");
printf("|-----------NHS Queue Control-----------|\n");
printf("| Create New Patient \t- Press 1\t|\n");
printf("| Delete Patient \t- Press 2\t|\n");
printf("| Find Patient \t\t- Press 3\t|\n");
printf("| List Queue \t\t- Press 4\t|\n");
printf("| Treate Next Patient \t- Press 5\t| \n");
printf("| Quit \t\t\t- Press 6\t|\n");
printf("|_______________________________________|\ n");
printf("Choice: ");
scanf("%d",&Choice);
printf("\n");
//Choice made, carrying out function
switch (Choice){
//New Patient
case 1:
limit = n;
if(limit < 21){
You never use limit so why do you care what it's value is.
> list_queue();
There is no prototype in scope for this function.
> printf("\nPlease enter the following details\n");
printf("What Queue Number would you like to place this patient
to?\n");
scanf("%d", &Qnum);
printf("Patient ID: ");
On a buffered system, calls to printf that don't end with a '\n' may
not appear before the system waits for input. If you want the input
to appear on the same line as the prompt, you should add
fflush(stdout);
to insure the buffer is flushed to the stream.
> scanf("%d", &patient[20].id);
Every use of patient[20] invokes undefined behavior. The valid
subscripts are 0 through 19 (MAXPATIENTS-1).
> printf("Forename: ");
scanf("%s", patient[20].forename);
printf("Middle Initial: ");
scanf("%c ", &patient[20].initial);
This will cause problems with any following calls to scanf. To enter
the initial, you will have to press two keys, one for the letter and
one for ENTER. This will result in two characters in the input
stream, one for the letter and a '\n' for the ENTER. The %c will only
consume the letter. The '\n' will stay in the stream and terminate
the next scanf prematurely.
> printf("Surname: ");
scanf("%s ", patient[20].surname);
printf("Maximum Waiting Time: ");
scanf("%d ", &patient[20].max_wait);
patient[20].day_of_entry = day_now();
error = insert_patient(Qnum, patient[20]);
While it is perfectly legal to pass a struct, the common
recommendation is to pass a pointer to the struct if the structure is
larger that trivial.
> if(error == -1){
printf("Error - Patient exists!\n");
}
else {
printf("\nPatient Inserted!\n");
}
}
else {
printf("Array is Full!\n");
}
break;
}
return 0;
}

//This is the add function
int insert_patient(int index, struct details newpatient) {
int i = 0;
int n = 0;
int y = find_patient_id(index) ;
There is no prototype in scope for this function. You also forgot to
provide the definition of this function.
> int x;
int error;

FILE * fptr; //Declares file pointer as "fptr"
Do you really think this comment contains any useful information?
> fptr = fopen("queue.dat", "r");
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){
You already read the records into patient back in main. Why are you
reading them again?
> n++;
}
fclose(fptr);

if(y == -1){
fptr = fopen("queue.dat", "w");
for(i=0;i<=index-2;i++){
fprintf(fptr,"%d ",patient[i].id);
fprintf(fptr,"%s ",patient[i].forename);
fprintf(fptr,"%c ",patient[i].initial);
You write the fields of the record with no intervening characters
between them. How is your call to fscanf supposed to know where
forename ends and initial begins?
> fprintf(fptr,"%s ",patient[i].surname);
fprintf(fptr,"%d ",patient[i].day_of_entry);
fprintf(fptr,"%d \n",patient[i].max_wait);
Ditto between surname and both integer fields or between day_of_entry
and max_wait.
> }

fprintf(fptr,"%d ",patient[20].id);
patient[20] still does not exist.
> fprintf(fptr,"%s ",patient[20].forename);
fprintf(fptr,"%c ",patient[20].initial);
fprintf(fptr,"%s ",patient[20].surname);
fprintf(fptr,"%d ",patient[20].day_of_entry);
fprintf(fptr,"%d \n",patient[20].max_wait);

for(x=index;x<=n+1;x++){
Why n+1? This insures you will process extraneous data. Fortunately
(or un-), the data is initialized since patient is at file scope.

Did you mean n-1? That would make sense but the common idiom is
i < n, not i <= n-1.
> fprintf(fptr,"%d ",patient[x].id);
fprintf(fptr,"%s ",patient[x].forename);
fprintf(fptr,"%c ",patient[x].initial);
fprintf(fptr,"%s ",patient[x].surname);
fprintf(fptr,"%d ",patient[x].day_of_entry);
fprintf(fptr,"%d \n",patient[x].max_wait);
}
error = 0;
}
else if (y != 0){
error = -1;
}
fclose(fptr);
return error;
}

Remove del for email
May 28 '07 #2
On 28 May, 21:23, Barry Schwarz <schwa...@doezl.netwrote:
On 28 May 2007 12:14:33 -0700, "chu...@gmail.com" <chu...@gmail.com>
wrote:
Ok Here is a problem, I got a imaginary database program that I need
to code, to add a patient I have function inser_patient. but when I
try to input the details it doesn't quite work the way I wanted it to.

Are we supposed to guess what you are talking about? What did you
want? What actually happened?


Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define MAXPATIENTS 20
struct details {
int id;
char forename[20];
char initial;
char surname[20];
int day_of_entry;
int max_wait;
};
struct details patient[MAXPATIENTS];
int npatients = 0;
int insert_patient(int index, struct details newpatient);
int main (void) {
int Choice;
int id;
int loop = 1;
int n=0;
int error=0;
int limit;
int Qnum;
FILE * fptr; //Declares file pointer as "fptr"
fptr = fopen("queue.dat", "r"); //Opens queue.dat to fptr

You should verify that fopen succeeded.
//Reading
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){

This is the wrong test. fscanf returns EOF only if no data was
converted. You should be proceeding only if the return value is 6.
n++;

You never check for n overflowing the number of elements in your
array.
}
fclose(fptr);
//Loop that continues the program
while(loop != 0){
//To keep program running
//Displaying Menu
printf("\n\n");
printf("%d \n",day_now());
printf("_________________________________________\ n");
printf("|-----------NHS Queue Control-----------|\n");
printf("| Create New Patient \t- Press 1\t|\n");
printf("| Delete Patient \t- Press 2\t|\n");
printf("| Find Patient \t\t- Press 3\t|\n");
printf("| List Queue \t\t- Press 4\t|\n");
printf("| Treate Next Patient \t- Press 5\t| \n");
printf("| Quit \t\t\t- Press 6\t|\n");
printf("|_______________________________________|\ n");
printf("Choice: ");
scanf("%d",&Choice);
printf("\n");
//Choice made, carrying out function
switch (Choice){
//New Patient
case 1:
limit = n;
if(limit < 21){

You never use limit so why do you care what it's value is.
list_queue();

There is no prototype in scope for this function.
printf("\nPlease enter the following details\n");
printf("What Queue Number would you like to place this patient
to?\n");
scanf("%d", &Qnum);
printf("Patient ID: ");

On a buffered system, calls to printf that don't end with a '\n' may
not appear before the system waits for input. If you want the input
to appear on the same line as the prompt, you should add
fflush(stdout);
to insure the buffer is flushed to the stream.
scanf("%d", &patient[20].id);

Every use of patient[20] invokes undefined behavior. The valid
subscripts are 0 through 19 (MAXPATIENTS-1).
printf("Forename: ");
scanf("%s", patient[20].forename);
printf("Middle Initial: ");
scanf("%c ", &patient[20].initial);

This will cause problems with any following calls to scanf. To enter
the initial, you will have to press two keys, one for the letter and
one for ENTER. This will result in two characters in the input
stream, one for the letter and a '\n' for the ENTER. The %c will only
consume the letter. The '\n' will stay in the stream and terminate
the next scanf prematurely.
printf("Surname: ");
scanf("%s ", patient[20].surname);
printf("Maximum Waiting Time: ");
scanf("%d ", &patient[20].max_wait);
patient[20].day_of_entry = day_now();
error = insert_patient(Qnum, patient[20]);

While it is perfectly legal to pass a struct, the common
recommendation is to pass a pointer to the struct if the structure is
larger that trivial.
if(error == -1){
printf("Error - Patient exists!\n");
}
else {
printf("\nPatient Inserted!\n");
}
}
else {
printf("Array is Full!\n");
}
break;
}
return 0;
}
//This is the add function
int insert_patient(int index, struct details newpatient) {
int i = 0;
int n = 0;
int y = find_patient_id(index) ;

There is no prototype in scope for this function. You also forgot to
provide the definition of this function.
int x;
int error;
FILE * fptr; //Declares file pointer as "fptr"

Do you really think this comment contains any useful information?
fptr = fopen("queue.dat", "r");
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){

You already read the records into patient back in main. Why are you
reading them again?
n++;
}
fclose(fptr);
if(y == -1){
fptr = fopen("queue.dat", "w");
for(i=0;i<=index-2;i++){
fprintf(fptr,"%d ",patient[i].id);
fprintf(fptr,"%s ",patient[i].forename);
fprintf(fptr,"%c ",patient[i].initial);

You write the fields of the record with no intervening characters
between them. How is your call to fscanf supposed to know where
forename ends and initial begins?
fprintf(fptr,"%s ",patient[i].surname);
fprintf(fptr,"%d ",patient[i].day_of_entry);
fprintf(fptr,"%d \n",patient[i].max_wait);

Ditto between surname and both integer fields or between day_of_entry
and max_wait.
}
fprintf(fptr,"%d ",patient[20].id);

patient[20] still does not exist.
fprintf(fptr,"%s ",patient[20].forename);
fprintf(fptr,"%c ",patient[20].initial);
fprintf(fptr,"%s ",patient[20].surname);
fprintf(fptr,"%d ",patient[20].day_of_entry);
fprintf(fptr,"%d \n",patient[20].max_wait);
for(x=index;x<=n+1;x++){

Why n+1? This insures you will process extraneous data. Fortunately
(or un-), the data is initialized since patient is at file scope.

Did you mean n-1? That would make sense but the common idiom is
i < n, not i <= n-1.
fprintf(fptr,"%d ",patient[x].id);
fprintf(fptr,"%s ",patient[x].forename);
fprintf(fptr,"%c ",patient[x].initial);
fprintf(fptr,"%s ",patient[x].surname);
fprintf(fptr,"%d ",patient[x].day_of_entry);
fprintf(fptr,"%d \n",patient[x].max_wait);
}
error = 0;
}
else if (y != 0){
error = -1;
}
fclose(fptr);
return error;
}

Remove del for email

So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait
Thanks
Chris

May 28 '07 #3
On 28 May, 21:23, Barry Schwarz <schwa...@doezl.netwrote:
On 28 May 2007 12:14:33 -0700, "chu...@gmail.com" <chu...@gmail.com>
wrote:
Ok Here is a problem, I got a imaginary database program that I need
to code, to add a patient I have function inser_patient. but when I
try to input the details it doesn't quite work the way I wanted it to.

Are we supposed to guess what you are talking about? What did you
want? What actually happened?


Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define MAXPATIENTS 20
struct details {
int id;
char forename[20];
char initial;
char surname[20];
int day_of_entry;
int max_wait;
};
struct details patient[MAXPATIENTS];
int npatients = 0;
int insert_patient(int index, struct details newpatient);
int main (void) {
int Choice;
int id;
int loop = 1;
int n=0;
int error=0;
int limit;
int Qnum;
FILE * fptr; //Declares file pointer as "fptr"
fptr = fopen("queue.dat", "r"); //Opens queue.dat to fptr

You should verify that fopen succeeded.
//Reading
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){

This is the wrong test. fscanf returns EOF only if no data was
converted. You should be proceeding only if the return value is 6.
n++;

You never check for n overflowing the number of elements in your
array.
}
fclose(fptr);
//Loop that continues the program
while(loop != 0){
//To keep program running
//Displaying Menu
printf("\n\n");
printf("%d \n",day_now());
printf("_________________________________________\ n");
printf("|-----------NHS Queue Control-----------|\n");
printf("| Create New Patient \t- Press 1\t|\n");
printf("| Delete Patient \t- Press 2\t|\n");
printf("| Find Patient \t\t- Press 3\t|\n");
printf("| List Queue \t\t- Press 4\t|\n");
printf("| Treate Next Patient \t- Press 5\t| \n");
printf("| Quit \t\t\t- Press 6\t|\n");
printf("|_______________________________________|\ n");
printf("Choice: ");
scanf("%d",&Choice);
printf("\n");
//Choice made, carrying out function
switch (Choice){
//New Patient
case 1:
limit = n;
if(limit < 21){

You never use limit so why do you care what it's value is.
list_queue();

There is no prototype in scope for this function.
printf("\nPlease enter the following details\n");
printf("What Queue Number would you like to place this patient
to?\n");
scanf("%d", &Qnum);
printf("Patient ID: ");

On a buffered system, calls to printf that don't end with a '\n' may
not appear before the system waits for input. If you want the input
to appear on the same line as the prompt, you should add
fflush(stdout);
to insure the buffer is flushed to the stream.
scanf("%d", &patient[20].id);

Every use of patient[20] invokes undefined behavior. The valid
subscripts are 0 through 19 (MAXPATIENTS-1).
printf("Forename: ");
scanf("%s", patient[20].forename);
printf("Middle Initial: ");
scanf("%c ", &patient[20].initial);

This will cause problems with any following calls to scanf. To enter
the initial, you will have to press two keys, one for the letter and
one for ENTER. This will result in two characters in the input
stream, one for the letter and a '\n' for the ENTER. The %c will only
consume the letter. The '\n' will stay in the stream and terminate
the next scanf prematurely.
printf("Surname: ");
scanf("%s ", patient[20].surname);
printf("Maximum Waiting Time: ");
scanf("%d ", &patient[20].max_wait);
patient[20].day_of_entry = day_now();
error = insert_patient(Qnum, patient[20]);

While it is perfectly legal to pass a struct, the common
recommendation is to pass a pointer to the struct if the structure is
larger that trivial.
if(error == -1){
printf("Error - Patient exists!\n");
}
else {
printf("\nPatient Inserted!\n");
}
}
else {
printf("Array is Full!\n");
}
break;
}
return 0;
}
//This is the add function
int insert_patient(int index, struct details newpatient) {
int i = 0;
int n = 0;
int y = find_patient_id(index) ;

There is no prototype in scope for this function. You also forgot to
provide the definition of this function.
int x;
int error;
FILE * fptr; //Declares file pointer as "fptr"

Do you really think this comment contains any useful information?
fptr = fopen("queue.dat", "r");
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){

You already read the records into patient back in main. Why are you
reading them again?
n++;
}
fclose(fptr);
if(y == -1){
fptr = fopen("queue.dat", "w");
for(i=0;i<=index-2;i++){
fprintf(fptr,"%d ",patient[i].id);
fprintf(fptr,"%s ",patient[i].forename);
fprintf(fptr,"%c ",patient[i].initial);

You write the fields of the record with no intervening characters
between them. How is your call to fscanf supposed to know where
forename ends and initial begins?
fprintf(fptr,"%s ",patient[i].surname);
fprintf(fptr,"%d ",patient[i].day_of_entry);
fprintf(fptr,"%d \n",patient[i].max_wait);

Ditto between surname and both integer fields or between day_of_entry
and max_wait.
}
fprintf(fptr,"%d ",patient[20].id);

patient[20] still does not exist.
fprintf(fptr,"%s ",patient[20].forename);
fprintf(fptr,"%c ",patient[20].initial);
fprintf(fptr,"%s ",patient[20].surname);
fprintf(fptr,"%d ",patient[20].day_of_entry);
fprintf(fptr,"%d \n",patient[20].max_wait);
for(x=index;x<=n+1;x++){

Why n+1? This insures you will process extraneous data. Fortunately
(or un-), the data is initialized since patient is at file scope.

Did you mean n-1? That would make sense but the common idiom is
i < n, not i <= n-1.
fprintf(fptr,"%d ",patient[x].id);
fprintf(fptr,"%s ",patient[x].forename);
fprintf(fptr,"%c ",patient[x].initial);
fprintf(fptr,"%s ",patient[x].surname);
fprintf(fptr,"%d ",patient[x].day_of_entry);
fprintf(fptr,"%d \n",patient[x].max_wait);
}
error = 0;
}
else if (y != 0){
error = -1;
}
fclose(fptr);
return error;
}

Remove del for email

So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait
Thanks
Chris

May 28 '07 #4
On 28 May, 21:23, Barry Schwarz <schwa...@doezl.netwrote:
On 28 May 2007 12:14:33 -0700, "chu...@gmail.com" <chu...@gmail.com>
wrote:
Ok Here is a problem, I got a imaginary database program that I need
to code, to add a patient I have function inser_patient. but when I
try to input the details it doesn't quite work the way I wanted it to.

Are we supposed to guess what you are talking about? What did you
want? What actually happened?


Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define MAXPATIENTS 20
struct details {
int id;
char forename[20];
char initial;
char surname[20];
int day_of_entry;
int max_wait;
};
struct details patient[MAXPATIENTS];
int npatients = 0;
int insert_patient(int index, struct details newpatient);
int main (void) {
int Choice;
int id;
int loop = 1;
int n=0;
int error=0;
int limit;
int Qnum;
FILE * fptr; //Declares file pointer as "fptr"
fptr = fopen("queue.dat", "r"); //Opens queue.dat to fptr

You should verify that fopen succeeded.
//Reading
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){

This is the wrong test. fscanf returns EOF only if no data was
converted. You should be proceeding only if the return value is 6.
n++;

You never check for n overflowing the number of elements in your
array.
}
fclose(fptr);
//Loop that continues the program
while(loop != 0){
//To keep program running
//Displaying Menu
printf("\n\n");
printf("%d \n",day_now());
printf("_________________________________________\ n");
printf("|-----------NHS Queue Control-----------|\n");
printf("| Create New Patient \t- Press 1\t|\n");
printf("| Delete Patient \t- Press 2\t|\n");
printf("| Find Patient \t\t- Press 3\t|\n");
printf("| List Queue \t\t- Press 4\t|\n");
printf("| Treate Next Patient \t- Press 5\t| \n");
printf("| Quit \t\t\t- Press 6\t|\n");
printf("|_______________________________________|\ n");
printf("Choice: ");
scanf("%d",&Choice);
printf("\n");
//Choice made, carrying out function
switch (Choice){
//New Patient
case 1:
limit = n;
if(limit < 21){

You never use limit so why do you care what it's value is.
list_queue();

There is no prototype in scope for this function.
printf("\nPlease enter the following details\n");
printf("What Queue Number would you like to place this patient
to?\n");
scanf("%d", &Qnum);
printf("Patient ID: ");

On a buffered system, calls to printf that don't end with a '\n' may
not appear before the system waits for input. If you want the input
to appear on the same line as the prompt, you should add
fflush(stdout);
to insure the buffer is flushed to the stream.
scanf("%d", &patient[20].id);

Every use of patient[20] invokes undefined behavior. The valid
subscripts are 0 through 19 (MAXPATIENTS-1).
printf("Forename: ");
scanf("%s", patient[20].forename);
printf("Middle Initial: ");
scanf("%c ", &patient[20].initial);

This will cause problems with any following calls to scanf. To enter
the initial, you will have to press two keys, one for the letter and
one for ENTER. This will result in two characters in the input
stream, one for the letter and a '\n' for the ENTER. The %c will only
consume the letter. The '\n' will stay in the stream and terminate
the next scanf prematurely.
printf("Surname: ");
scanf("%s ", patient[20].surname);
printf("Maximum Waiting Time: ");
scanf("%d ", &patient[20].max_wait);
patient[20].day_of_entry = day_now();
error = insert_patient(Qnum, patient[20]);

While it is perfectly legal to pass a struct, the common
recommendation is to pass a pointer to the struct if the structure is
larger that trivial.
if(error == -1){
printf("Error - Patient exists!\n");
}
else {
printf("\nPatient Inserted!\n");
}
}
else {
printf("Array is Full!\n");
}
break;
}
return 0;
}
//This is the add function
int insert_patient(int index, struct details newpatient) {
int i = 0;
int n = 0;
int y = find_patient_id(index) ;

There is no prototype in scope for this function. You also forgot to
provide the definition of this function.
int x;
int error;
FILE * fptr; //Declares file pointer as "fptr"

Do you really think this comment contains any useful information?
fptr = fopen("queue.dat", "r");
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){

You already read the records into patient back in main. Why are you
reading them again?
n++;
}
fclose(fptr);
if(y == -1){
fptr = fopen("queue.dat", "w");
for(i=0;i<=index-2;i++){
fprintf(fptr,"%d ",patient[i].id);
fprintf(fptr,"%s ",patient[i].forename);
fprintf(fptr,"%c ",patient[i].initial);

You write the fields of the record with no intervening characters
between them. How is your call to fscanf supposed to know where
forename ends and initial begins?
fprintf(fptr,"%s ",patient[i].surname);
fprintf(fptr,"%d ",patient[i].day_of_entry);
fprintf(fptr,"%d \n",patient[i].max_wait);

Ditto between surname and both integer fields or between day_of_entry
and max_wait.
}
fprintf(fptr,"%d ",patient[20].id);

patient[20] still does not exist.
fprintf(fptr,"%s ",patient[20].forename);
fprintf(fptr,"%c ",patient[20].initial);
fprintf(fptr,"%s ",patient[20].surname);
fprintf(fptr,"%d ",patient[20].day_of_entry);
fprintf(fptr,"%d \n",patient[20].max_wait);
for(x=index;x<=n+1;x++){

Why n+1? This insures you will process extraneous data. Fortunately
(or un-), the data is initialized since patient is at file scope.

Did you mean n-1? That would make sense but the common idiom is
i < n, not i <= n-1.
fprintf(fptr,"%d ",patient[x].id);
fprintf(fptr,"%s ",patient[x].forename);
fprintf(fptr,"%c ",patient[x].initial);
fprintf(fptr,"%s ",patient[x].surname);
fprintf(fptr,"%d ",patient[x].day_of_entry);
fprintf(fptr,"%d \n",patient[x].max_wait);
}
error = 0;
}
else if (y != 0){
error = -1;
}
fclose(fptr);
return error;
}

Remove del for email

So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait
Thanks
Chris

May 28 '07 #5
On 28 May, 21:23, Barry Schwarz <schwa...@doezl.netwrote:
On 28 May 2007 12:14:33 -0700, "chu...@gmail.com" <chu...@gmail.com>
wrote:
Ok Here is a problem, I got a imaginary database program that I need
to code, to add a patient I have function inser_patient. but when I
try to input the details it doesn't quite work the way I wanted it to.

Are we supposed to guess what you are talking about? What did you
want? What actually happened?


Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define MAXPATIENTS 20
struct details {
int id;
char forename[20];
char initial;
char surname[20];
int day_of_entry;
int max_wait;
};
struct details patient[MAXPATIENTS];
int npatients = 0;
int insert_patient(int index, struct details newpatient);
int main (void) {
int Choice;
int id;
int loop = 1;
int n=0;
int error=0;
int limit;
int Qnum;
FILE * fptr; //Declares file pointer as "fptr"
fptr = fopen("queue.dat", "r"); //Opens queue.dat to fptr

You should verify that fopen succeeded.
//Reading
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){

This is the wrong test. fscanf returns EOF only if no data was
converted. You should be proceeding only if the return value is 6.
n++;

You never check for n overflowing the number of elements in your
array.
}
fclose(fptr);
//Loop that continues the program
while(loop != 0){
//To keep program running
//Displaying Menu
printf("\n\n");
printf("%d \n",day_now());
printf("_________________________________________\ n");
printf("|-----------NHS Queue Control-----------|\n");
printf("| Create New Patient \t- Press 1\t|\n");
printf("| Delete Patient \t- Press 2\t|\n");
printf("| Find Patient \t\t- Press 3\t|\n");
printf("| List Queue \t\t- Press 4\t|\n");
printf("| Treate Next Patient \t- Press 5\t| \n");
printf("| Quit \t\t\t- Press 6\t|\n");
printf("|_______________________________________|\ n");
printf("Choice: ");
scanf("%d",&Choice);
printf("\n");
//Choice made, carrying out function
switch (Choice){
//New Patient
case 1:
limit = n;
if(limit < 21){

You never use limit so why do you care what it's value is.
list_queue();

There is no prototype in scope for this function.
printf("\nPlease enter the following details\n");
printf("What Queue Number would you like to place this patient
to?\n");
scanf("%d", &Qnum);
printf("Patient ID: ");

On a buffered system, calls to printf that don't end with a '\n' may
not appear before the system waits for input. If you want the input
to appear on the same line as the prompt, you should add
fflush(stdout);
to insure the buffer is flushed to the stream.
scanf("%d", &patient[20].id);

Every use of patient[20] invokes undefined behavior. The valid
subscripts are 0 through 19 (MAXPATIENTS-1).
printf("Forename: ");
scanf("%s", patient[20].forename);
printf("Middle Initial: ");
scanf("%c ", &patient[20].initial);

This will cause problems with any following calls to scanf. To enter
the initial, you will have to press two keys, one for the letter and
one for ENTER. This will result in two characters in the input
stream, one for the letter and a '\n' for the ENTER. The %c will only
consume the letter. The '\n' will stay in the stream and terminate
the next scanf prematurely.
printf("Surname: ");
scanf("%s ", patient[20].surname);
printf("Maximum Waiting Time: ");
scanf("%d ", &patient[20].max_wait);
patient[20].day_of_entry = day_now();
error = insert_patient(Qnum, patient[20]);

While it is perfectly legal to pass a struct, the common
recommendation is to pass a pointer to the struct if the structure is
larger that trivial.
if(error == -1){
printf("Error - Patient exists!\n");
}
else {
printf("\nPatient Inserted!\n");
}
}
else {
printf("Array is Full!\n");
}
break;
}
return 0;
}
//This is the add function
int insert_patient(int index, struct details newpatient) {
int i = 0;
int n = 0;
int y = find_patient_id(index) ;

There is no prototype in scope for this function. You also forgot to
provide the definition of this function.
int x;
int error;
FILE * fptr; //Declares file pointer as "fptr"

Do you really think this comment contains any useful information?
fptr = fopen("queue.dat", "r");
while (fscanf(fptr,"%d %s %c %s %d %d[^\n]", &patient[n].id,
patient[n].forename, &patient[n].initial, patient[n].surname,
&patient[n].day_of_entry, &patient[n].max_wait) != EOF){

You already read the records into patient back in main. Why are you
reading them again?
n++;
}
fclose(fptr);
if(y == -1){
fptr = fopen("queue.dat", "w");
for(i=0;i<=index-2;i++){
fprintf(fptr,"%d ",patient[i].id);
fprintf(fptr,"%s ",patient[i].forename);
fprintf(fptr,"%c ",patient[i].initial);

You write the fields of the record with no intervening characters
between them. How is your call to fscanf supposed to know where
forename ends and initial begins?
fprintf(fptr,"%s ",patient[i].surname);
fprintf(fptr,"%d ",patient[i].day_of_entry);
fprintf(fptr,"%d \n",patient[i].max_wait);

Ditto between surname and both integer fields or between day_of_entry
and max_wait.
}
fprintf(fptr,"%d ",patient[20].id);

patient[20] still does not exist.
fprintf(fptr,"%s ",patient[20].forename);
fprintf(fptr,"%c ",patient[20].initial);
fprintf(fptr,"%s ",patient[20].surname);
fprintf(fptr,"%d ",patient[20].day_of_entry);
fprintf(fptr,"%d \n",patient[20].max_wait);
for(x=index;x<=n+1;x++){

Why n+1? This insures you will process extraneous data. Fortunately
(or un-), the data is initialized since patient is at file scope.

Did you mean n-1? That would make sense but the common idiom is
i < n, not i <= n-1.
fprintf(fptr,"%d ",patient[x].id);
fprintf(fptr,"%s ",patient[x].forename);
fprintf(fptr,"%c ",patient[x].initial);
fprintf(fptr,"%s ",patient[x].surname);
fprintf(fptr,"%d ",patient[x].day_of_entry);
fprintf(fptr,"%d \n",patient[x].max_wait);
}
error = 0;
}
else if (y != 0){
error = -1;
}
fclose(fptr);
return error;
}

Remove del for email

So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait
Thanks
Chris

May 28 '07 #6
<ch****@gmail.comwrote:
On 28 May, 21:23, Barry Schwarz <schwa...@doezl.netwrote:
>On 28 May 2007 12:14:33 -0700, "chu...@gmail.com" <chu...@gmail.com>
wrote:
>Ok Here is a problem, I got a imaginary database program that I need
to code, to add a patient I have function inser_patient. but when I
try to input the details it doesn't quite work the way I wanted it to.

Are we supposed to guess what you are talking about? What did you
want? What actually happened?


>Code:
>#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
>#define MAXPATIENTS 20
>struct details {
int id;
char forename[20];
char initial;
char surname[20];
int day_of_entry;
int max_wait;
};
>struct details patient[MAXPATIENTS];
int npatients = 0;
<snip>
So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait
You start by either fixing the things Barry mentioned or state why his
objections were not valid. Then, post that modified, indented, code, with a
question inserted somewhere in the post.
May 28 '07 #7
On 28 May, 22:37, "osmium" <r124c4u...@comcast.netwrote:
<chu...@gmail.comwrote:
On 28 May, 21:23, Barry Schwarz <schwa...@doezl.netwrote:
On 28 May 2007 12:14:33 -0700, "chu...@gmail.com" <chu...@gmail.com>
wrote:
Ok Here is a problem, I got a imaginary database program that I need
to code, to add a patient I have function inser_patient. but when I
try to input the details it doesn't quite work the way I wanted it to.
Are we supposed to guess what you are talking about? What did you
want? What actually happened?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define MAXPATIENTS 20
struct details {
int id;
char forename[20];
char initial;
char surname[20];
int day_of_entry;
int max_wait;
};
struct details patient[MAXPATIENTS];
int npatients = 0;

<snip>
So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait

You start by either fixing the things Barry mentioned or state why his
objections were not valid. Then, post that modified, indented, code, with a
question inserted somewhere in the post.

printf("Forename: ");
scanf("%s", patient[20].forename);
printf("Middle Initial: ");
scanf("%c ", &patient[20].initial);
This will cause problems with any following calls to scanf. To enter
the initial, you will have to press two keys, one for the letter and
one for ENTER. This will result in two characters in the input
stream, one for the letter and a '\n' for the ENTER. The %c will only
consume the letter. The '\n' will stay in the stream and terminate
the next scanf prematurely.

How do I prevent this from ending prematurely?? by changing
&patient[20].initial to &patient[19].initial ??

May 28 '07 #8
<ch****@gmail.comwrote:
On 28 May, 22:37, "osmium" <r124c4u...@comcast.netwrote:
><chu...@gmail.comwrote:
On 28 May, 21:23, Barry Schwarz <schwa...@doezl.netwrote:
On 28 May 2007 12:14:33 -0700, "chu...@gmail.com" <chu...@gmail.com>
wrote:
>Ok Here is a problem, I got a imaginary database program that I need
to code, to add a patient I have function inser_patient. but when I
try to input the details it doesn't quite work the way I wanted it
to.
>Are we supposed to guess what you are talking about? What did you
want? What actually happened?
>Code:
>#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
>#define MAXPATIENTS 20
>struct details {
int id;
char forename[20];
char initial;
char surname[20];
int day_of_entry;
int max_wait;
};
>struct details patient[MAXPATIENTS];
int npatients = 0;

<snip>
So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait

You start by either fixing the things Barry mentioned or state why his
objections were not valid. Then, post that modified, indented, code, with
a
question inserted somewhere in the post.


printf("Forename: ");
> scanf("%s",
patient[20].forename);
printf("Middle Initial: ");
scanf("%c ",
&patient[20].initial);

This will cause problems with any following calls to scanf. To enter
the initial, you will have to press two keys, one for the letter and
one for ENTER. This will result in two characters in the input
stream, one for the letter and a '\n' for the ENTER. The %c will only
consume the letter. The '\n' will stay in the stream and terminate
the next scanf prematurely.

How do I prevent this from ending prematurely?? by changing
&patient[20].initial to &patient[19].initial ??
You can read two keys by

scanf("%c%c", &a, &junk) ;

where a and junk are variables of type char.

Note that your quoting mechanism is messed up.
May 28 '07 #9
On May 29, 12:43 am, "osmium" <r124c4u...@comcast.netwrote:
<chu...@gmail.comwrote:
On 28 May, 22:37, "osmium" <r124c4u...@comcast.netwrote:
<chu...@gmail.comwrote:
On 28 May, 21:23, Barry Schwarz <schwa...@doezl.netwrote:
On 28 May 2007 12:14:33 -0700, "chu...@gmail.com" <chu...@gmail.com>
wrote:
Ok Here is a problem, I got a imaginary database program that I need
to code, to add a patient I have function inser_patient. but when I
try to input the details it doesn't quite work the way I wanted it
to.
Are we supposed to guess what you are talking about? What did you
want? What actually happened?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define MAXPATIENTS 20
struct details {
int id;
char forename[20];
char initial;
char surname[20];
int day_of_entry;
int max_wait;
};
struct details patient[MAXPATIENTS];
int npatients = 0;
<snip>
So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait
You start by either fixing the things Barry mentioned or state why his
objections were not valid. Then, post that modified, indented, code, with
a
question inserted somewhere in the post.
printf("Forename: ");
scanf("%s",
patient[20].forename);
printf("Middle Initial: ");
scanf("%c ",
&patient[20].initial);
This will cause problems with any following calls to scanf. To enter
the initial, you will have to press two keys, one for the letter and
one for ENTER. This will result in two characters in the input
stream, one for the letter and a '\n' for the ENTER. The %c will only
consume the letter. The '\n' will stay in the stream and terminate
the next scanf prematurely.
How do I prevent this from ending prematurely?? by changing
&patient[20].initial to &patient[19].initial ??

You can read two keys by

scanf("%c%c", &a, &junk) ;

where a and junk are variables of type char.

Note that your quoting mechanism is messed up.
What do you mean by my quoting mechanism??

May 29 '07 #10
On 28 May 2007 14:35:43 -0700, "ch****@gmail.com" <ch****@gmail.com>
wrote:
snip 240 lines of irrelevant history
>So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait
Thanks
Chris
Posting the same message every 10-20 minutes only serves to get you
ignored.
Remove del for email
May 29 '07 #11
ch****@gmail.com wrote:
On May 29, 12:43 am, "osmium" <r124c4u...@comcast.netwrote:
>>
Note that your quoting mechanism is messed up.

What do you mean by my quoting mechanism??
That last post was a good example, you quoted the entire message to
respond to one line. Learn to trim.

--
Ian Collins.
May 29 '07 #12
Barry Schwarz <sc******@doezl.netwrites:
On 28 May 2007 14:35:43 -0700, "ch****@gmail.com" <ch****@gmail.com>
wrote:
snip 240 lines of irrelevant history
>>So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait
Thanks
Chris

Posting the same message every 10-20 minutes only serves to get you
ignored.
I've seen a lot of that kind of thing recently, all of it from Google
Groups users. It may not be entirely the OP's fault.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
May 29 '07 #13
<ch****@gmail.comwrote:
This will cause problems with any following calls to scanf. To enter
the initial, you will have to press two keys, one for the letter and
one for ENTER. This will result in two characters in the input
stream, one for the letter and a '\n' for the ENTER. The %c will only
consume the letter. The '\n' will stay in the stream and terminate
the next scanf prematurely.
>Note that your quoting mechanism is messed up.

What do you mean by my quoting mechanism??
The paragraph above that starts "this will cause" was written by Barry
Shwartz. The post I responded to had no so it looked to me like something
*you* had written. Look at the post you made preceding this one.
May 29 '07 #14
On Mon, 28 May 2007 18:33:52 -0700, Keith Thompson <ks***@mib.org>
wrote:
>Barry Schwarz <sc******@doezl.netwrites:
>On 28 May 2007 14:35:43 -0700, "ch****@gmail.com" <ch****@gmail.com>
wrote:
snip 240 lines of irrelevant history
>>>So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait
Thanks
Chris

Posting the same message every 10-20 minutes only serves to get you
ignored.

I've seen a lot of that kind of thing recently, all of it from Google
Groups users. It may not be entirely the OP's fault.
When several messages have the same timestamp, I'm willing to accept
that the user thought it didn't go through. When it's four messages
spread out pretty evenly over 40 minutes, I'll bet the sender thinks
he is in a chat room.
Remove del for email
May 29 '07 #15
On 28 May 2007 13:56:09 -0700, in comp.lang.c , "ch****@gmail.com"
<ch****@gmail.comwrote:

(snip 250 lines)
>
So how do I avoid the program from skipping when I try to type in the
max_wait, in patient[20].max_wait
You reposted the /entire/ article, just to add a small question .
Please learn to trim articles down when following up.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
May 29 '07 #16
On 28 May 2007 15:37:01 -0700, "ch****@gmail.com" <ch****@gmail.com>
wrote:
printf("Forename: ");
scanf("%s", patient[20].forename);
printf("Middle Initial: ");
scanf("%c ", &patient[20].initial);

This will cause problems with any following calls to scanf. To enter
No it won't -- or not for the reason you state; all the out-of-bounds
references to patient[20] are U.B. as already noted several times.

Also, I haven't seen anyone mention it yet (although I may have missed
it), but it is U.B. if you use %s for a char array of size N and the
input contains contiguous nonwhitespace of more than N-1 characters.
To be safe you should use e.g. %19s for a char[20] data field.
Or better, fgets() into a nice long line buffer and check whether the
value overflows your storage space, and give a nice clear error
message and/or allow retry. Or better yet, use a data structure that
allows for longer values, or variable-length (dynamic) values. (Either
or both of which are actually useful lessons to learn.)
the initial, you will have to press two keys, one for the letter and
one for ENTER. This will result in two characters in the input
stream, one for the letter and a '\n' for the ENTER. The %c will only
consume the letter. The '\n' will stay in the stream and terminate
Those are true.
the next scanf prematurely.
That's not. The trailing space in the format string "%c " will skip
ALL whitespace -- including but not limited to the newline.

Alternatively, if the next scanf is any format specifier other than c
or [...] (or doubled % if you count that as a specifier) then it will
skip _leading_ whitespace. In the code upthread the next scanf is in
fact "%s" for "Surname" which does skip whitespace.
How do I prevent this from ending prematurely?? by changing
&patient[20].initial to &patient[19].initial ??
Moot.

Aside: Quite a lot of people have names that don't fit the rigid mold
the program upthread demands. If this were a real system and not just
homework, and your system denied medical treatment to people because
of their names, you would be in BIG trouble -- probably in jail.

- formerly david.thompson1 || achar(64) || worldnet.att.net
Jul 1 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
5
by: titan0111 | last post by:
#include<iostream> #include<iomanip> #include<cstring> #include<fstream> using namespace std; class snowfall { private: int ft;
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
56
by: Cherrish Vaidiyan | last post by:
Frinds, Hope everyone is doing fine.i feel pointers to be the most toughest part in C. i have just completed learning pointers & arrays related portions. I need to attend technical interview on...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
9
by: Pyenos | last post by:
import cPickle, shelve could someone tell me what things are wrong with my code? class progress: PROGRESS_TABLE_ACTIONS= DEFAULT_PROGRESS_DATA_FILE="progress_data" PROGRESS_OUTCOMES=
3
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when...
24
by: MU | last post by:
Hello I have some code that sets a dropdownlist control with a parameter from the querystring. However, when the querystring is empty, I get an error. Here is my code: Protected Sub...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.