-
Character code
I'm suppose to write a user friendly programme using functions and modules to accept six names from a user and print to the screen the six names then ask the user which name they want deleted then print the remaining names after the name is deleted then notify the user which name was deleted.
This is what i have come up with thus far.
printf("Which name would you like deleted?\n");
scanf("%s",&pie);
for(char egg=0; egg<=5; egg++)
{
if (myarray[egg]!=pie)
{
printf("%s",myarray[egg]);
printf(" ");
}
}
return 0;
}
and i have also tried this as well
#include <stdio.h>
void getnames()
{
printf("Enter six names \n");
for(int i=0;i<=5;i++)
{
scanf("%s",nameArr[i]);
}
}
void display()
{
for (int j=0;j< name;j++)
{
printf("\n %s ",nameArr[j]);
printf("\n");
}
}
void main()
{
getnames();
display();
printf("What do you want to delete");
remove();
display();
}
void remove()
{
printf("\nPlease Enter the name you want to deleted");
scanf_s("%d",&val);
for(int mad=0;mad<=5;mad++)
{
if(temp[mad]==val)
{
temp[mad]=val;
}
else
{
printf("%d",temp[mad]);
printf(" ");
}
}
return 0;
}
[/CODE]
-
Neither void main nor char main is standard; use int main to begin with.
Then I suggest you go back and re-learn how to read strings, because you certainly do not read them into int arrays.
And read my signature about reading strings with scanf or use fgets.
And then select all your code and press Alt+F8 to indent it. You've made a mistake in a loop, as well.