User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 427,097 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,324 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 6044 | Replies: 5
Reply
Join Date: Nov 2003
Posts: 1
Reputation: PeteECU is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
PeteECU PeteECU is offline Offline
Newbie Poster

Completely new to C++ and have question about using char

  #1  
Nov 2nd, 2003
Hello all, I will start off by saying Im in the dark with some aspects of C++, in an intro computer course at college. My question is about how to use char commands for when I have multiple users using the same segment of C++.

ex.

3 users are asked to enter their height etc..... Im not sure how to go about the it for 3, 1 user is easy and I have no problem.

Any thoughts or how to's would be appreciated

Thanks
Pete
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2003
Posts: 4
Reputation: ShadowBranch is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ShadowBranch ShadowBranch is offline Offline
Newbie Poster

Re: Completely new to C++ and have question about using char

  #2  
Nov 3rd, 2003
use an array for your place holder. try doing it like this:
char height[] = new char[3];
this tells char that you are making an array. now, to access this you would do something like this, say to output in the dos-type command prompt of most beggining c++ classes
cout << "Height of 1 is: " << height[0];
the last space in the array is always NULL or \0. they are the same thing. now to just go through the array and print all of them you would do this:
for(i = 0; i < 3; i++){
cout << "Height of " << i << " is: " << height[i];
}
this would print everything in the array except the last byte which is NULL or \0. later one you will get to dynamic arrays which will be set to \0 or NULL before you start using them. But that is beside the point.
Reply With Quote  
Join Date: Sep 2003
Posts: 22
Reputation: Mike29936 is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 0
Mike29936 Mike29936 is offline Offline
Newbie Poster

Re: Completely new to C++ and have question about using char

  #3  
Nov 3rd, 2003
What do you mean 3 users using your program? You're only going to have 1 user to your program, unless it's internet based.

If ya' mean 3 different inputs to teh program:

#include <stdio.h>
#define users 3

int main(void) {
printf("Input %d heights:",users);
int loop = 0;
double temp[users];
while (loop < users) {
scanf("%f",&temp[loop]);
loop++;
}
return 0;
}

Change #define users 3 to #define users x, where x is the number of users your want.

Or something...
Reply With Quote  
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 25
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Completely new to C++ and have question about using char

  #4  
Nov 4th, 2003
Oh no... a While Loop. Run!
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Join Date: Dec 2003
Posts: 14
Reputation: sammy is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
sammy sammy is offline Offline
Newbie Poster

Re: Completely new to C++ and have question about using char

  #5  
Dec 10th, 2003
paladine, I don't believe your code is in c++. It seems to me like the old structured c.
Reply With Quote  
Join Date: Sep 2003
Posts: 22
Reputation: Mike29936 is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 0
Mike29936 Mike29936 is offline Offline
Newbie Poster

Re: Completely new to C++ and have question about using char

  #6  
Dec 20th, 2003
Well, I prefer printf() to cout. If the guy wants, he can change printf() to cout, and scanf() to cin.

But they do the same thing, so it doesn't really matter.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 5:32 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC