LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 03-20-2008, 06:18 AM   #1
lppc2112
LQ Newbie
 
Registered: Mar 2008
Posts: 7

Rep: Reputation: 0
Post stl


how do i use data structures, array or a vector to store some vertices??
how to implement in the program and where?

here is my code

#include<map>
#include<iostream>
#include<string>
#include<fstream>
#include<sstream>
#include <vector>

using std::istringstream;
using std::ifstream;
using std::string;
using std::cout;
using std::cin;
using std::cerr;
using std::map;
using std::multimap;
using namespace std;

/*struct obj
{
float x,y,z;

};

obj vertices,face,normals

vertices.x
face.y
normals.z


*/

int main()
{

multimap<string,int> words;
map<int,string> lines;
string str;
ifstream input("rohr1.obj"); //create file for input
if(input.fail())
{
cerr<<"\nThe file could not be opened.";
return -1;
}

int i=1;
while(getline(input,str))
{
istringstream in(str);
string s;
while(in>>s)
{
words.insert(make_pair(s,i));
}
lines.insert(make_pair(i,str));
i++;
}
string search;
cout<<"\nEnter a word to search: ";
cin>>search;
cout<<"\nThe number of matches = "<<words.count(search)<<'\n';
multimap<string,int>::iterator it1=words.lower_bound(search);
multimap<string,int>::iterator it2=words.upper_bound(search);
while(it1!=it2)
{
int x=it1->second;
map<int,string>::iterator iter=lines.find(x);
cout<<'\n'<<x<<" ) "<<iter->second<<'\n';
it1++;
while(true)
{
if(it1!=it2 && it1->second==x)
{
it1++;

}
else
{
break;
}
}
}

cout<<'\n';

return 0;
}
 
Old 03-20-2008, 09:54 AM   #2
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Removed from zero replies.
Please do not post your question multiple times:
http://www.linuxquestions.org/questi...amming-627833/
http://www.linuxquestions.org/questi...amming-627011/
Also note that people here are not prepared do your homework for you.
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
c++ -> need help for STL library linstef Linux - Software 2 01-21-2007 09:53 AM
Hello from STL oakleyd LinuxQuestions.org Member Intro 1 12-15-2006 11:03 PM
STL online help available ? carcassonne Programming 3 07-12-2006 05:49 PM
c++ and stl G67 Programming 4 12-17-2003 02:36 AM
C++ STL problem jaycee999 Programming 5 05-31-2002 03:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration