#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main(){
char name[80];
char *searchptr;
int i, t; 


for(i=1; name[i]!=EOF; i++){
printf( "Enter name\n");
scanf("%s", &name[i]);
}

for(t=i; t<=0; t--){
printf(" name[%d] == %s", i, name[t]);

getch();
return 0;
}}

Recommended Answers

All 2 Replies

help plz, i am trying to input some names and then output them

I suggest using a 2D character array

@ line 12:
1. array indexes start at 0
2. since your not using files why use EOF? do yo expect that the user would input a negative value? I believe you can use a much simpler alternative for this


@ line 17:
1. why start at the last value of i then decrement as if you want to view the array backwards?
2. the loop condition won't be met
3. why is the return statement for main at the loop?

Also, you can't put a char value to "%s" (@line14 &18).
name is a char variable;
name is a char array or you may call it string in C);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.