Hi guys…
I want to write small program in C printing three or more people in array..how? please write to me the syntax as I am very poor in C..

How to define the name? and accept the conformation from the user? Either by yes or no

The printing should be like
Your name is (first name in array)
Your name is (second name in array)

Do you need to use Loop?

Recommended Answers

All 5 Replies

please i really need help

first, you need to write main() function

#include <stdio.h>

int main()

   // put your code here

next declare a character array that will hold the name that you input from the keyboard

#include <stdio.h>

int main()

   char name[80]; // allow up to 79 characters plus null terminator
   // put your code here

call printf() to display the prompt, and fgets() to get the input from the keyboard.

print("... < text goes here > ... ");

Hi Ancient,
Thanks for your help,
well, that slove first part of the probelm, i think i need to have a loop...

Assume, I have three elements in array – test[‘A’ , ‘B’ , ‘C’]

I want in the printf function to print this Question with each element

Are you Mr. A
Are you Mr, B
Are you Mr. C

Waiting your support

why wait for anyone to tell you -- try it yourself and find out.

I want in the printf function to print this Question with each element

Why use printf? Just use cout.
Also, why use a char array when the STL provides a string class?

If it's three or MORE people then use a vector since you don't know the exact size.

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.