Question
I need nelp with this kind of error in my 6 program to make it works: ve2.c:74:1: warning: control may reach end of non-void function
I need nelp with this kind of error in my 6 program to make it works:
ve2.c:74:1: warning: control may reach end of non-void function [-Wreturn-type]
Particulary in the 3 functions :
The code:
#include
#include
char arr[26][26];
char message[22], key[22], emessage[22], retMessage[22];
int findRow(char);
int findColumn(char);
int findDecRow(char, int);
int main()
{
int i = 0, j, k, r, c;
k = 96;
for (i = 0; i
{
k++;
for (j = 0; j
{
arr[i][j] = k++;
if (k == 123)
k = 97;
}
}
printf(" Enter message ");
fgets(message, 22, stdin);
printf(" Enter the key ");
fgets(key, 22, stdin);
for (i = 0; key[i] != '\0'; i++) //Use '\0', not NULL
{
c = findRow(key[i]);
r = findColumn(message[i]);
emessage[i] = arr[r][c];
}
emessage[i] = '\0';
printf(" Encrypted message is: ");
for (i = 0; emessage[i] != '\0'; i++) //Use '\0', not NULL
printf("%c", emessage[i]);
//decryption
for (i = 0; key[i] != '\0'; i++) //Use '\0', not NULL
{
c = findColumn(key[i]);
r = findDecRow(emessage[i], c);
retMessage[i] = arr[r][0];
}
printf(" Message Retrieved is: ");
for (i = 0; emessage[i] != '\0'; i++) //Use '\0', not NULL
printf("%c", emessage[i]);
//decryption
for (i = 0; key[i] != '\0'; i++) //Use '\0', not NULL
{
c = findColumn(key[i]);
r = findDecRow(emessage[i], c);
retMessage[i] = arr[r][0];
}
retMessage[i] = '\0';
printf(" Message Retrieved is: ");
for (i = 0; retMessage[i+1] != '\0'; i++)
printf("%c", retMessage[i]);
getchar();
return(0);
}
int findRow(char c)
{
int i;
for (i = 0; i
{
if (arr[0][i] == c)
return (i);
}
}
int findColumn(char c)
{
int i;
for (i = 0; i
{
if (arr[i][0] == c)
return (i);
}
}
int findDecRow(char c, int j)
{
int i;
for (i = 0; i
{
if (arr[i][j] == c)
return (i);
}
}
output should be:
ve2.c:74:1: warning control may reach end of non-void function [-Wreturn-type] ve2.c:84:1: warning control may reach end of non-void function [-Wreturn-type] ve2.c:93:1: warning control may reach end of non-void function [-Wreturn-type] 3 warnings generatedStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started