Originally Posted by
Hodor
Maybe start by understanding the code below. It probably has nothing to do with your flowchart but at least it makes sense and compiles.
In this case, I would like to work on my code
When ever get function return success first pass A then array content other print stop message
Code:
#include<stdio.h>
#define failure 1
#define success 0
int SendD (unsigned int A, unsigned int n, int *pointer)
int main ()
{
int p;
int A = 0;
int n = 5;
int i;
int array[4] = {1, 2, 3, 4};
p = SendD(A, n, array);
return 0;
}
int get()
{
int Value;
printf("Enter digit : ");
scanf("%d", Value);
if( Value == 1)
return failure;
else
return success;
}
void send(int D)
{
int i;
for (i=0; i<8; i++)
{
printf("%d\n", D);
}
}
int SendD (unsigned int A, unsigned int n, int *pointer)
{
int value, a;
printf("Start \n");
send(A);
value = get();
if (value == failure)
printf("Stop \n");
else
if (n == 0)
printf("Stop \n");
else
a = *pointer;
send(a);
printf("%d ", a);
value = get();
if (value == failure)
printf("Stop \n");
else
++pointer;
n--;
return value;
}
Start
0
0
0
0
0
0
0
0
Enter digit : 0
When get function return 0, pass value pointed by pointer that is array[0] = 1;
line 58 it should be display 1 that is array[0] = 1;