Forum: C++ 28 Days Ago |
| Replies: 1 Views: 361 // strings and c-strings
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
using namespace std;
vector<string> SplitString (string aString)
{ |
Forum: C++ Oct 13th, 2009 |
| Replies: 3 Views: 291 Next time don't leave your h/w to the last minute. |
Forum: C++ Oct 11th, 2009 |
| Replies: 8 Views: 325 oops i meant
vector<bool>setlist;
setlist.push_back(true);
setlist.push_back(false);
setlist.push_back(true);
setlist.push_back(true); |
Forum: C++ Oct 11th, 2009 |
| Replies: 8 Views: 325 I think your easiest answer would be
vector<int>setlist;
setlist.push_back(3);
setlist.push_back(12);
setlist.push_back(4);
string s1 = ",";
cout << "{"; |
Forum: C++ Oct 11th, 2009 |
| Replies: 8 Views: 325 Well at the end can't you just do an string erase on the last but one element?
string p = "{1,2,3,24,}";
p.erase(p.length()-2,1); |
Forum: C++ Sep 28th, 2009 |
| Replies: 23 Views: 667 Well if you WANT to allow duplicates all you need is a std::vector |
Forum: C++ Sep 28th, 2009 |
| Replies: 23 Views: 667 >! myfile.eof()
using that is not advised.
And use std::string instead. |
Forum: C++ Sep 17th, 2009 |
| Replies: 3 Views: 571 set a variable at the beginning then add them all up:
eg.
int total = 0;
for ( int i = 0; i < 10; i++ )
{
total = total + i;
} |
Forum: C++ Aug 26th, 2009 |
| Replies: 11 Views: 518 Maybe might be of use?
http://www.daniweb.com/code/snippet900.html |
Forum: C++ Jul 21st, 2009 |
| Replies: 8 Views: 352 > BTW, iamthwee, you forgot a zero at the end of the number
yeah a typo, I still think you need the +1 which makes the answer
30.89, which rounds to 31?
For example in his example:
4th week... |
Forum: C++ Jul 21st, 2009 |
| Replies: 8 Views: 352 #include <cmath>
#include <iostream>
using namespace std;
int main ()
{
cout << ( log ( 100000000.0 ) / log ( 2.0 ) ) + 1;
getchar();
} |
Forum: C++ Jul 21st, 2009 |
| Replies: 8 Views: 352 Just thinking aloud so most probably wrong.
Can't you just take logs to find the answer? |
Forum: C++ Jul 20th, 2009 |
| Replies: 14 Views: 564 int i = 0;
while ( std::getline ( inFileStream, line ) )
{
file[i] = line;
//cout <<line<<endl;
i++;
} |
Forum: C++ Jul 13th, 2009 |
| Replies: 4 Views: 319 Or those of you that like using std:strings etc.
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
int lowercase ( int c )
{ |
Forum: C++ Jun 26th, 2009 |
| Replies: 17 Views: 472 I'm sorry but that doesn't tell us much.
Post all your code including your text file and the code you use to read in that password. |
Forum: C++ Jun 23rd, 2009 |
| Replies: 6 Views: 291 Yes, but the OP already stated in another thread, that he/she is forced to use turbo c++ at their school. |
Forum: C++ Jun 8th, 2009 |
| Replies: 3 Views: 472 Well can't use just do #include <string> in main() then? |
Forum: C++ Jun 8th, 2009 |
| Replies: 8 Views: 252 Well do you know what pass by reference means, if not read up on it. |
Forum: C++ Jun 8th, 2009 |
| Replies: 8 Views: 252 & is pass by reference is that what you require? |
Forum: C++ Jun 8th, 2009 |
| Replies: 8 Views: 252 why have you got a temp, surely you would just pop anything that is negative and that's that. |
Forum: C++ May 29th, 2009 |
| Replies: 8 Views: 469 try changing
char a;
a = 'A';
to:
string a;
a = "A";
and do a |
Forum: C++ May 27th, 2009 |
| Replies: 2 Views: 168 maybe rec[0] == rec[rec.length()-1] |
Forum: C++ May 22nd, 2009 |
| Replies: 7 Views: 359 You need to give more details than that. What exactly are you using? |
Forum: C++ May 20th, 2009 |
| Replies: 5 Views: 241 |
Forum: C++ May 15th, 2009 |
| Replies: 6 Views: 247 You might be better asking this question in a GTK forum. |
Forum: C++ May 15th, 2009 |
| Replies: 11 Views: 446 Ah OK then I didn't realise find in <algorithm> was different. However, it doesn't excuse your profanity. |
Forum: C++ May 15th, 2009 |
| Replies: 11 Views: 446 > Bull-!@#$ of code was that. Simply lost all purpose of find()
Calm down chicken.
My example does probably what the OP requires in simpler terms.
find() returns an integer of the position of... |
Forum: C++ May 15th, 2009 |
| Replies: 11 Views: 446 Alternatively,
for ( int i = 0 ; i < v.size(); i++ )
{
if ( v[i].name == "Misco" )
{
cout << "FOUND\n";
cout << v[i].name << endl;
cout << v[i].age << endl;
} |
Forum: C++ May 13th, 2009 |
| Replies: 5 Views: 313 |
Forum: C++ May 7th, 2009 |
| Replies: 2 Views: 815 A bit different but you get the idea, here int y is the end position as opposed to the length.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std; |
Forum: C++ May 1st, 2009 |
| Replies: 2 Views: 498 Should be able to just do a comparison.
Maybe using the c-style string compare function. Can't remember what it is cos I never use c-style strings in c++ |
Forum: C++ Apr 29th, 2009 |
| Replies: 9 Views: 351 What do you mean it "isn't works"?
Do you get a compiler error, is the output completely wrong, is it just wrong by a bit. Tell us what you mean. |
Forum: C++ Apr 8th, 2009 |
| Replies: 19 Views: 1,340 http://www.daniweb.com/code/snippet233.html, oops missed the purpose of calculating last non-zero digit which makes the algorithm simpler. :) |
Forum: C++ Apr 5th, 2009 |
| Replies: 5 Views: 411 I see this as one of those clearing the console windows questions... |
Forum: C++ Mar 12th, 2009 |
| Replies: 10 Views: 923 cout << data[i] << "\n" << endl;
change to:
cout << data[i] << " "; |
Forum: C++ Mar 5th, 2009 |
| Replies: 7 Views: 835 Try this:
#include <iostream>
#include <string>
#include <stack>
class Foo
{
public: |
Forum: C++ Mar 1st, 2009 |
| Replies: 12 Views: 627 So what are you saying the page opens OK as a html on your local machine but not on your server? |
Forum: C++ Feb 21st, 2009 |
| Replies: 14 Views: 856 Looks OK to me, nicely separated into functions...
fflush(stdin) looks a bit dubious
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1052863818&id=1043284351 |
Forum: C++ Feb 4th, 2009 |
| Replies: 2 Views: 585 #include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
int main()
{ |
Forum: C++ Jan 15th, 2009 |
| Replies: 13 Views: 1,074 Use of std::strings etc? No? |