Click here to Skip to main content
15,886,026 members
Articles / Programming Languages / C++

char array issue with scope

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
8 Nov 2012CPOL 3.6K  
Hey guys,I need to make a program that reads a user inputted (cin) line and stores it in a char array. easy?cout << "Enter your name" << endl;cin.getline(name, 50);name's declared as an array.This is fine... but I need it in a seperate function that returns the data to main......

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
8 Nov 2012Stefan_Lang
If you hate scopes, why do you artificially create many more of them than you need? Every time you write int or char you define a new variable of that type, and thereby create a scope. The only places that require a type are declarations: function declarations or variable declarations.Your...
Please Sign up or sign in to vote.
8 Nov 2012fjdiewornncalwe
You need to make some effort on your own first. That means you need to post code that you have written first, and we'll help you get it right. We won't do the work for you.Homework, and why we don't do it.[^] (Compliments of JSOP)
Please Sign up or sign in to vote.
8 Nov 2012Chuck O'Toole
Question: How many times do you need to type char in your code? Hint, you have too many of them.Question: How many times do you need to type int in your code? Hint, you have an extra one in there somewhere.Question: What good is the variable i in the subroutine Names? You don't use...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions