Archived

This topic is now archived and is closed to further replies.

Questions about VC++

This topic is 5893 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

1.) How do you use the getline fn. In Microsoft Visual C++. getline(cin,title); 2.) Is there any substitue for the gotoxy(12,10) fn in MVC++? 3.) How do you use a string type in MVC++? I''ve just putting the word ''string'' as a data type. It works in Borland. 4.) How do you use--> cout.setf(iso::showpoint); iso class fn''s and flags. The compilers getting aggitated with those as well. thanx -Sage13

Share this post


Link to post
Share on other sites
quote:
Original post by Sage13
1.) How do you use the getline fn. In Microsoft Visual C++.


I think you use cin->getline(buffer , buffer_len );
quote:

2.) Is there any substitue for the gotoxy(12,10) fn in MVC++?


That sets the text cursor position, right?

I don't know of any direct substitute, but I imagine there is one. You'd want to look up consoles in the MSDN (which is available online at msdn.microsoft.com)
quote:

3.) How do you use a string type in MVC++?


The STL has a string type, called string. If you include the right file (I don't know what it is since I'm not using anything from the STL).

quote:

4.) How do you use--> cout.setf(iso::showpoint);


In what way is it aggitated? If showpoint is a function, then that's not going to work. If showpoint contains flags then it's badly named, but that wouldn't stop it working. Perhaps it's not static? Non-static variables can only be accessed via an instance of the class.


Signatures? We don't need no steenking signatures!

Edited by - Mayrel on October 30, 2001 2:27:50 PM

Share this post


Link to post
Share on other sites
quote:
Original post by Sage13
1.) How do you use the getline fn. In Microsoft Visual C++.
getline(cin,title);

Do
cin.getline(); 
instead. Look up its parameters in MSDN.

quote:
2.) Is there any substitue for the gotoxy(12,10) fn in MVC++?

gotoxy() is a DOS/console function. If you''re working on the Windows Console, use SetConsoleCursorPos(COORD c); (you need to set the X and Y data members of the COORD struct first). Alternatively, you can look up Standard C Library functions.

quote:
3.) How do you use a string type in MVC++?
I''ve just putting the word ''string'' as a data type. It works in Borland.

Move to the Standard C++ Library. It has a wonderful type called string . Here''s how to use it:

#include <iostream> // the C++ standard library iostream
#include <string>
using std::string; // string is a part of the std namespace .
using std::cout;
using std::cin;
using std::endl;
// use the using keyword to import either elements
// from a namespace or the entire namespace:
// you could have written "using namespace std;" instead
int main(int argc, char *argv[])
{
string str; // a string object
cout << "Please enter a string: ";
cin >> str; // there is an overloaded insertion operator for string
cout << "The string you entered was: \"" << str << "\"" << endl;
return 0;
}

If you need to get a C-style string from your string object, use its c_str() method.

quote:
4.) How do you use--> cout.setf(iso::showpoint);
iso class fn''s and flags. The compilers getting aggitated with those as well.

That would be ios , not iso. I;m not sure what you''re trying to accomplish, so post a description of your objective and we might be able to give you better alternatives.

Share this post


Link to post
Share on other sites