im having trouble with my program here.
i'll show you my codes but its quite long.
Code:
typedef struct
{
float quantity,
calorie;
string15 unit;
string20 fditem;
}calType;
typedef struct
{
string70 step;
}stepType;
typedef struct
{
string50 title;
int serving;
char course;
calType content[20];
stepType steps[15];
int nContents;
}structRecipeType;
struct node
{
structRecipeType structRecipe;
calType structcalType;
int nUsed;
struct node *pNext;
struct node *pPrevious;
struct node *pcNext;
struct node *pcPrevious;
};
typedef struct node PtrType;
typedef PtrType *ptrPointer;
void mAddStep(ptrPointer *pFirst)
{
int x=0, i=0,ask=1,mod=1,where='\0',correct=1,n=0,ctr=0;
int bask=1, brun=1;
char cDump,BA;
ptrPointer pMod;
stepType TEMPs[15],move;
while(mod==1)
{
if(ask==1)
{
pMod=*pFirst;
i=0;
clrscr();
printf("Recipe Title: %s\n",pMod->structRecipe.title);
printf("--------------------------------------------------\n");
while(pMod->structRecipe.steps[i].step[0]!='\0'&&i!=20)
{
printf("%d. %s\n",i+1,pMod->structRecipe.steps[i].step);
i++;
}
printf("--------------------------------------------------\n");
printf("Enter Information: ");
fgets(TEMPs.step,sizeof(string70),stdin);
TEMPs.step[strlen(TEMPs.step)-1]='\0';
printf("Enter where to insert: ");
scanf("%d%c",&where,&cDump);
ctr=where;
while(pMod->structRecipe.steps[where-1].step[0]!='\0')
{
strcpy(move.step,pMod->structRecipe.steps[ctr+1].step);
strcpy(pMod->structRecipe.steps[ctr+1].step,pMod->structRecipe.steps[ctr-1].step);
strcpy(pMod->structRecipe.steps[].step)
ctr++;
}
strcpy(pMod->structRecipe.steps[where-1].step,TEMPs.step);
ask=0;
mod=0;
}
}
}
In the main program it calls this function to edit *pFirst which is a structRecipeType, so my problem is.
im having trouble with moving the other values in my pMod->structRecipe.steps[].step
down 1 more value after where i insert the new value.
Values:
1.Step 1
2.Step 2
3.Step 3
Example Input: Step 4 at number 2
result:
1.Step 1
2.Step 4
3.Step 2
4.Step 3