R
ritchie
Hi,
Just wanted to ask if anybody has any idea what i'm doing wrong.
I have a function which edits a linked list. It works fine.
I pass in a pointer to the list plus the value of the item to be
edited.
The value to be edited is a string which has been converted to an int
using atoi.
It is converted fine, then I pass this value to the function and when
I try to access the LL values I get an access violation error.
I debugged the code and I cannot figure out what's going wrong.
I also tried converting the string to an int in the same way, within
the edit function and this works fine.
Has anyone experienced this before??
Thanks in advance,
Ritchie.
/***************************code*************************/
-----------------------------------------
Function call in main --
editList( &nStart, convertDate( ) );
(value returned is correct)
-----------------------------------------
int convert( ) /*takes input as string & converts to int */
{
char sYear[1], sMonth[1], sDay[1], sFullDate[9]="";
int iFullDate=0;
printf("Enter day (dd): "); scanf("%s", sDay);
printf("Enter month (mm): "); scanf("%s", sMonth);
printf("Enter year (yyyy): "); scanf("%s", sYear);
strcat(sFullDate, sYear);
strcat(sFullDate, sMonth);
strcat(sFullDate, sDay);
/*convert full date to int*/
return iFullDate = atoi(sFullDate);
}
/*-------------------edit-------------------------------*/
void edit( NodePtr *sPtr, int iData)
{
NodePtr prevPtr, currPtr;
if( iData == (*sPtr)->iOrderDate.iFullDate ) /*THIS IS WHERE I GET
ERROR*/
{
printf("Account found > ");
...
...
...
/*********************************************************/
Just wanted to ask if anybody has any idea what i'm doing wrong.
I have a function which edits a linked list. It works fine.
I pass in a pointer to the list plus the value of the item to be
edited.
The value to be edited is a string which has been converted to an int
using atoi.
It is converted fine, then I pass this value to the function and when
I try to access the LL values I get an access violation error.
I debugged the code and I cannot figure out what's going wrong.
I also tried converting the string to an int in the same way, within
the edit function and this works fine.
Has anyone experienced this before??
Thanks in advance,
Ritchie.
/***************************code*************************/
-----------------------------------------
Function call in main --
editList( &nStart, convertDate( ) );
(value returned is correct)
-----------------------------------------
int convert( ) /*takes input as string & converts to int */
{
char sYear[1], sMonth[1], sDay[1], sFullDate[9]="";
int iFullDate=0;
printf("Enter day (dd): "); scanf("%s", sDay);
printf("Enter month (mm): "); scanf("%s", sMonth);
printf("Enter year (yyyy): "); scanf("%s", sYear);
strcat(sFullDate, sYear);
strcat(sFullDate, sMonth);
strcat(sFullDate, sDay);
/*convert full date to int*/
return iFullDate = atoi(sFullDate);
}
/*-------------------edit-------------------------------*/
void edit( NodePtr *sPtr, int iData)
{
NodePtr prevPtr, currPtr;
if( iData == (*sPtr)->iOrderDate.iFullDate ) /*THIS IS WHERE I GET
ERROR*/
{
printf("Account found > ");
...
...
...
/*********************************************************/