So this is my code..
vector<string> frame(const vector<string>& v){
vector<string> ret;
string::size_type maxlen = width(v);
string border(maxlen + 4, '*');
//write the top border
Type: Posts; User: dnguyen1022
So this is my code..
vector<string> frame(const vector<string>& v){
vector<string> ret;
string::size_type maxlen = width(v);
string border(maxlen + 4, '*');
//write the top border
I can see that if s.size() is greater than width1, a negative amount of spaces would be appended to string s, which I assume returns an error?
As for the words.size() being less than...
Hm..from what I think, the top loop keeps the same string around, while the second makes a new instance everytime. I would assume the first loop would just keep adding more characters to the...
So I'm following my C++ textbook and its asking me why the top one doesn't work but the bottom does. I see that string s is defined outside in one, and inside of the while loop in the other. When...
Thank you laserlight. it worked brilliantly!
I am using a list for the container.
As for your suggestion anon with the loop, I tried decrementing the iterator everytime i erased the element from the list, but it gives me an error saying the...
So I am trying to write up two versions of a function, that takes in a list of data structure of students(which consists of their name and grades), and filters out all the failing students, and...
Hm..sounds sort of complicated..what would say would be a "beginner" type of research? Say...at the low-mid undergrad levels. Excluding students who excel at what they do of course..
So I was thinking about possibly doing research in the future as a Computer Science major...however something left me kind of stumped. How does research work in Computer Science? For medical...
what does it mean with this part?
...which all the lines of the original picture are padded out to their full width
Hi all,
I need help understanding a problem given in the Accelerated C++ book on page 100, problem 5-5.
The problem states
Write a function named center(const vector<string>&) that returns a...
Okay so previously, I attempted to sort of create a generic type of program. I did this by using typedef to define two vectors. One of structs and one of doubles. However when I changed the...
Hello, so I am trying to create a small mini program that iterates through a vector and outputs something according to a book. I have no problem understanding the problem, but I came across a...
I am trying to do a problem that I can apply to both lists or vectors using an interator, and all I would have to do to change the problem is within a typedef declaration. However it does not...
Yes, or you can ask the user for the string rather than within the body of your code.
I apologize, but I renamed one of the argument variables as I was typing this up. I didn't realize it was the same name as the function. The book had it as "is" but sometimes I name whatever the...
from the way I understand it, it looks like you give it a number and a string. That number will determine what letter you start at from the string. From where you start at, determine if there are 4...
Hello all, so I am writing up a few programs according to the book. However I do not entirely get what it is saying.
istream& read(istream& read, Student_info& student){
read >>...
Ok I understand now, Thanks!...so with a code like this
//the containers
list<list<string>> sentences;
list<string> sentence;
string x;
//adds user input to container
Hello all,
So I have a question...So suppose I create a program that simply takes in my input and stores it into a list and then I output the list. Normally for my compiler (Vistual Studio), in...
Yes, this would work perfectly, but why would my last code not work? Does rbegin() not reference to the last element of the list?
Yes I am trying to loop through all the items except the last one.
If rbegin() is what I am looking for then this should work..but its not.
for(list<string>::iterator iter = phrase.begin();...
I dont know anything about the template, but I did get it off MSDN Software Alliance through my school.
It looks exactly like what I want, but for some reason I am getting an error with this piece of code.
for(list<string>::iterator iter = phrase.begin(); iter != phrase.back(); iter++){
...
Hello all, so I am trying to check for the last element in the list, but I don't know how. list.begin() is the first element, but list.end() is the one past the last element. Doing list.end()--...