Jump to content
  • Advertisement
Sign in to follow this  
hothead

got a problem with vector function at()

This topic is 5119 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

it is supposed to print "the first one 1" "the second one 2" I just fooled around with some code I saw don't know too much about it
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

int main()
{
	vector <int> v1;
	vector <int> v2;
	v1.push_back(1);
	v2.push_back(2);

	const int j = v1.at(0);
	const int i = v2.at(1);

	cout <<"the first one" << j << "\n";
	cout <<"the second one" << i << "\n";

	system("pause");
	return 0;
}
errors:LINK : fatal error LNK1201: error writing to program database 'c:\Documents and Settings\matt\My Documents\Visual Studio Projects\notf\Debug\notf.pdb'; check for insufficient disk space, invalid path, or insufficient privilege .

Share this post


Link to post
Share on other sites
Advertisement
Assuming you haven't actually used up all the storage on your hard drive, usually rebooting your computer and then doing a rebuild all will fix that problem.

Share this post


Link to post
Share on other sites
The error indicates that the program is still running when you attempt to build it. Go into your Task Manager and kill the existing copy.

As for the code, it's wrong. You push one value back onto both v1 and v2, but you attempt to index the second value in v2 - which is empty.

Share this post


Link to post
Share on other sites
Quote:
Original post by Oluseyi
The error indicates that the program is still running when you attempt to build it. Go into your Task Manager and kill the existing copy.

As for the code, it's wrong. You push one value back onto both v1 and v2, but you attempt to index the second value in v2 - which is empty.


ok

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!