| | |
C++ vectors problem
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2008
Posts: 10
Reputation:
Solved Threads: 0
hello everyone....i need some help,i am using c++ and vectors, and text files to create a library system and i have a problem.....i used a vector named v1 and i was trying to use an if else to assign a created vectors elements value to another value
example like v[10] is "Storybook5"
i tried this v[10]="storybook3"
and this also v.at(10)="storybook3"
it still will not change,it ll come out Storybook5
i need help.....this is my code.....
example like v[10] is "Storybook5"
i tried this v[10]="storybook3"
and this also v.at(10)="storybook3"
it still will not change,it ll come out Storybook5
i need help.....this is my code.....
C++ Syntax (Toggle Plain Text)
void LibraryMember::PrintLoanMem()//this is to print the members on loan,and reduce repetition of members { v1.clear(); ifstream loanfile("loan.txt"); string info; int i; int j; int count=0; int count2=0; if (loanfile.is_open()) { while(!loanfile.eof()) { getline(loanfile,info); v1.push_back(info); count++; } } count2=count; v1[3]=""; for(i=0;i<count;i++) { for(j=0;j<count2;j++) { if (v1[j]==v1[i]) { v1[j]==""; } } } ofstream out("loanMem.txt",ios::app); size_t size = v1.size(); for (size_t i = 0; i < size; i++) { if(v1.at(i)=="") { } else out << v1[i] <<endl; } }//end function printloan mem
Last edited by Ancient Dragon; Oct 5th, 2008 at 6:42 am. Reason: add code tags
Indeed, however i have a feeling it may be a similar problem to this....
What exactly does this do?
C++ Syntax (Toggle Plain Text)
if (v1[j]==v1[i]) { v1[j]==""; }
What exactly does this do?
Knowledge is power -- But experience is everything
![]() |
Similar Threads
- Counting the amount of different words with vectors? (C++)
- Vectors Versus Arrays (Java)
- Pointer, vector, and/or deque problem (C++)
- Messy array things. (C++)
- Using Vectors and Arrays with fstream (C++)
- minor problem with vectors and OOP (C++)
- Vectors, Functions, and Sorting... oh my! (C++)
Other Threads in the C++ Forum
- Previous Thread: Compiling on cmd...
- Next Thread: C++.
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






