siddhant3s 1,429 Practically a Posting Shark

>Try this, it works
Why do you think I didn't gave him the code?
Anyways, here is my version.

#include <iostream>
#include <string>
#include <cctype>

std::string sentn_case(std::string s)
{
    size_t pos=0;
    //Capatalize the beigning of the string
    while (!isalpha(s[pos])) pos++;
    s[pos]=toupper(s[pos]);

    //Now find the period and split the string for next recursion
    pos=s.find(".");
    if (pos==std::string::npos)return s;

    while (!isalpha(s[pos])) pos++;
    return s.substr(0,pos)+sentn_case(s.substr(pos));
}
int main()
{
    std::string s=\
" and then a voice came over.\" hello. how are you. mister\"";
    std::cout<<sentn_case(s)<<std::endl;
}

The actual function is just 7 lines!
My solution may be less efficient (considering it uses recursion) but quite elegant.

@ArkM code: The output from your function was: And then a voice came over."hello. How are you. Mister"

iamthwee commented: And what are you doing here. Stop the spoon feeding! -4
siddhant3s 1,429 Practically a Posting Shark

>>But I dont know the correct way to do it?
What you are doing is ``just" acceptable. It is no where near to what one would called a good code.
I suggest you to use the infamous Unix philosophy KISS( Keep it Simple and Stupid).
Although I am not a big fan of recursion, these problems are best nail for the recursion-hammer.

Consider this:
Write a Small function say, sentence_case(string s) whose job is strictly to do this:
* Take a string.
* Capitalize the First alpha-character after the encounter of the first period(lets say the first encounter of the first alpha-character preceded by a period was at k-th subscript.)
* Return s.substr(0,k)+sentence_case(substr(k, s.size-k) ) That is the corrected_part+ the sentence_case(uncorrected_part)
* This will again call sentence_case on the rest of the string.
* If there is no occurrence of a period, Return the String s, as-is.

I don't know how much you appreciate good programming technique but the one you are applying will lead into what is called the 'adhocity trap'. It won't be months, when you will again look up your code and won't be able to recognize what you did.

The member function you would require are : string::find, string::substr and sting::size You can find reference about these on http://www.cplusplus.com/reference/string/string/
Good Luck

siddhant3s 1,429 Practically a Posting Shark

>Yes, yes it is. But printf and scanf are a part of C++ as well. It's not uncommon to >drop down to stdio when iostreams are too slow.
I don't know what made me type that but I think I was in illusion that the OP has posted some C code here.
I don't think the standards says anything about iostream being slower? (Though it usually are (though the difference is insignificant) )

>Speak for yourself. I d.................
It is pretty ovbious that I was trying to discourage him using printfs.
If it satisfies you " My backspace key was not working" ;)

siddhant3s 1,429 Practically a Posting Shark

>I tried using scanf and printf but still wont happen in 2 seconds
I told you to use file I/O. Use fopen fread.
By the way this is a C++ forum and not a C forum. We usually don't understand printf and scanf.

siddhant3s 1,429 Practically a Posting Shark

>I can't understand why your brutal force algorithm is so expensive
It will certainly not be. But he may be getting 100 of Input tests at once. So it may exceed the time limit ( which is about 2-3 seconds ).

siddhant3s 1,429 Practically a Posting Shark

I won't have to.
When you create an object of class C, both get_a, get_b will be available for calling.
If however, both function was named get(), then it would cause ambiguity.

class A
{
	protected:
		int no;

	public:
		void get(void)
		{
		cout<<"Class";
		}

};
class B
{
	protected:
		int no1;
	public:
		void get_a(void)
		{

		cout<<"Class";
		}

};
class C : public A,B
{
	private:
		int no;


};

//inside main
C c;
c.get() //error. which get()?
c.A::get() //oh, so you mean A' get. No problem
Nick Evan commented: Signing off for today, so here's a wave goodbye. See you in a year! +18
siddhant3s 1,429 Practically a Posting Shark

>i am usin turbo C in window XP
I am sorry, your code is rusted. That is not a surprise since you are using such a crappy compiler.
I have written a guide to help people like you in long run. Although it is not complete, but it will serve you good. Read it at:
http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html

Ancient Dragon commented: ++ link to excellent blog :) +36
Salem commented: Nice link, but Stroustrup needs better spelling in several places. +33
tux4life commented: There was need to something like this +8
siddhant3s 1,429 Practically a Posting Shark

As Tux4Life demonstrated, array are often given credit that they save a lot of typing work by cutting short the declaration of many variables in just one go.
But actually there is some more advantage of using an array except just to save multiple declaration.
The advantage of array lies in that each element can be called from their indexes which can be determined at the run time.
This is a bit different from what tux demonstrated.
Continuing Tux4life's example lets say you write a program which displays the marks of the student, whose roll number is entered by user. Without arrays: the program will look like this:

cout<<"Enter Roll Number";
int rno;
cin>>rno;
if(rno==1)
   print(p1_s1,p1_s2,p1_s3,p1_s4);
if(rno==2)
   print(p2_s1,p2_s2,p2_s3,p2_s4);
if(rno==3)
   print(p3_s1,p3_s2,p3_s3,p3_s4);
.
.
.
//till 20 cases

I know the above example could have been done by using a switch case, the problem remain same.

If, however arrays are used:

cout<<"Enter Roll Number";
int rno;
cin>>rno;
for(int i=0;i<4;i++)
   print(scores[rno][i]);
//Thats it
siddhant3s 1,429 Practically a Posting Shark

To tux:http://www.cplusplus.com/reference/iostream/istream/getline/
"Characters are extracted until either (n - 1) characters have been extracted or the delimiting character is found (which is delim if this parameter is specified, or '\n' otherwise). The extraction also stops if the end of file is reached in the input sequence or if an error occurs during the input operation"

EDIT Dave:Umm, Guess you were faster. Dani is loading real slow. I am thus using a console based browser. Sorry couldn't see you :)

siddhant3s 1,429 Practically a Posting Shark

Now thats what I call a script kiddie.

>I Can Program basic Online Codez :CSS and HTML.
You do not program in HTML. HTML is not a programming language. It is a markup language.


Consider yourself quite lucky. Because hackers don't usualy repsonz 2 sm1 who cnnt wrte pr0per1y. Plz lern englis wel it is d languazz of d int3rn3t.

siddhant3s 1,429 Practically a Posting Shark

Ya there solution is pretty trivial. Kummer Theorem is the right way.
The answer would the exact power of the five in the given number.
AFAIR: the exact power was calculated as
[tex]\sum_{n=1}^{\infty}floor(\frac{N}{p^n})[/tex]
where N is the number and p =5 in this case. This sum is actually finite since all the terms to the right of the(and including) term where N< p^n will be zero.

siddhant3s 1,429 Practically a Posting Shark

The first optimization advice is "Don't optimize anything".
Second advice: Stick to one language C or C++. You are using lot of scanfs and printfs.
It goes without say that post your code it code tags:

[code=cpp] //your code

[/code]

siddhant3s 1,429 Practically a Posting Shark

>>Hi, siddhant3s, I think it would be more helpful to the OP if you indent your code
Dear Tux4life, the code has been already indented by Astyle Free source code intender which is integrated on my Code::Blocks.

siddhant3s 1,429 Practically a Posting Shark

Take a paper, take a pen.
Scribble something until it makes sense.
Posting without trying is not wise,
It just show your ignorance.

Although we are here to solve your queries,
We, can't work until we have some berries.
Those berries are your tries,
So, don't post before attempting, it makes us cry.

One more thing I tell you my friend,
There is a page by Eric S Raymond.
Which you should read, here we pray,
and that page is "How to ask question the Smart way"
(Applause)
Thank You. Thank You.

This is revenge: you irritate me with your post and I irritate you with my poetry.

tux4life commented: Nice poetry :P +8
siddhant3s 1,429 Practically a Posting Shark

Simple, Use file I./O.
Or you can also use the input redirection operator '<' while calling the program from the command prompt $ myprogram.exe < input_data.txt

siddhant3s 1,429 Practically a Posting Shark

>Stop your spoon feeding
What are you upto my life. Just because I gave you infraction ones, you've started a mission to give me infractions.
I have made it already clear Why I delivered the code. Besides, my code was not as rusted as you usually post.
:(

siddhant3s 1,429 Practically a Posting Shark

>This helps, but to clarify, instead of taking a string of charecters from a text file and throwing
>them into an array, is it possible to take that same concept but do it with binary? Thanks

Yes, but don't expect that you would be able to display them. A binary file is a stream of unformatted character. That is, it is raw and does not follow ASCII standards. Hence your terminal won't be able to display it. But it sure can be dumped into a char array.

fstream f("asdf.dat");
char* arr=new char[ sizeof file];
f.read(reinterpret_cast<char*>(arr), size of file);
siddhant3s 1,429 Practically a Posting Shark

In that case change my 9th and 10th line to:

<< values.front();//return first
        values.erase( values.begin() );//delete first
siddhant3s 1,429 Practically a Posting Shark

Well, why are you not using std::strings?
I wrote a quick code with those. It is quite flexible:

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string input="(98415)4554-215245";
    string area,exchange,extention;
    
    {//these are added to limit the scope of c_brace & hyphen
        size_t c_brace=input.find(")");//closing brace
        size_t hyphen=input.find("-");//the hyphen
        area=input.substr(  1, c_brace -1);
        exchange= input.substr( c_brace+1, hyphen-c_brace-1);
        extention= input.substr(hyphen+1,input.size()-hyphen);
    }
    
    cout<<area<<" "<<exchange<<" "<<extention;
    return 0;
}

(Oh my. Python has started to influence my Cplusplus)
I know few advocates can sue me to give away code, but I am here demonstrating the power of using STL (the computational code is just 5 lines)

iamthwee commented: Stop your spoon feeding :) -4
siddhant3s 1,429 Practically a Posting Shark

You did not flushed the stream.
Read http://www.daniweb.com/forums/thread90228.html
Use cin.ignore(); to do this:

#include <iostream>
using namespace std;

int main()
{
    double f;
    double m;
    cout << "Enter the length in feet ";
    cin >> f;
    m = f / 3.28;
    cout << f << " feet equals " << m << " meters";
    cin.ignore();
    cin.get();
    return 0;
}

Also, always post your code in the code tags:
[code=cplusplus] //your code goes here

[/code]

siddhant3s 1,429 Practically a Posting Shark

Take a paper, take a pen.
Scribble something until it makes sense.
Posting without trying is not wise,
It just show your ignorance.

Although we are here to solve your queries,
We, can't work until we have some berries.
Those berries are your tries,
So, don't post before attempting, it makes us cry.

One more thing I tell you my friend,
There is a page by Eric S Raymond.
Which you should read, here we pray,
and that page is "How to ask question the Smart way"
(Applause)
Thank You. Thank You.

siddhant3s 1,429 Practically a Posting Shark

>I prefer option 2.
Same here.
But everyone should use option 2 if you are designing a converter, or a filter. It helps other program to use your program's output as their input.

siddhant3s 1,429 Practically a Posting Shark

Why are you not using vector::pop_back ?

do
{
    cout << "Press E to End or Press P to pop a value: ";
    cin >> selection;

    if (selection == 'p' || selection == 'P')
    {
        cout<<"The integer you popped was: "
        << values.back();//return last
        values.pop_back();//delete last
    }
    else
        break;
}while ( ! values.empty() );//till vector isn't empty
siddhant3s 1,429 Practically a Posting Shark

Yes. First you need to learn the Basic HTTP protocol. Here(http://www.jmarshall.com/easy/http/) is excellent tutorial for the same. It teaches the protocol by using telnet. Then you should learn about sockets (http://docs.python.org/library/socket.html). Also, read the Beej's Network Programming Tutorial (http://beej.us/guide/bgnet/) it would be helpful, although it is intended for C programmers.
Next use socket's send and receive functions to interact with the web server as you would do with a telnet program.

But I strongly don't recommend you to do all this fuss. UrlLib along with urlLib2 is very powerful library. It can do many things. Use it.

siddhant3s 1,429 Practically a Posting Shark

>ONE forward /
>or TWO backward \\
Don't advice him to use \\. It will make the code ugly and platform dependent. Always use one forward slash.
Learn: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.7 and http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.16

Anyways, Good Catch

siddhant3s 1,429 Practically a Posting Shark

>If You Want Something To Do, Try This Exercise...

If you are free, try this exercise:
Repeat 10 times a day : " Hackers aren't stupid. Programmers are not stupid."
And you will magically get the answer.

siddhant3s 1,429 Practically a Posting Shark

Create a file with all junk upto a maximum size:

x x x x x x x x x x
x x x x x x x x x x 
x x x x x x x x x x 
x x x x x x x x x x 
x x x x x x x x x x
x x x x x x x x x x

Now, whenever you want to write something in it, use the file pointers manipulators (as told by ArkM, the fseek) to place the write pointer to the particular location and then write your data:

a b c d e x x x x x
x x x x x x x x x x 
x x x x x x x x x x 
x x x x x x x x x x 
x x x x x x x x x x
x x x x x x x x x x

Of course, you will have to find divider which can differentiate between the junk and the good data.
I recommend that you store the size of the of the useful data at the beginning of each file:

6 a b c d e x x x x 
x x x x x x x x x x 
x x x x x x x x x x 
x x x x x x x x x x 
x x x x x …
siddhant3s 1,429 Practically a Posting Shark

>>is that the ans of my question?
Let me make you one thing clear. This is what Eric. S Raymond said on his article "How to ask question the smart way"

Never assume you are entitled to an answer. You are not; you aren't, after all, paying for the service. You will earn an answer, if you earn it, by asking a substantial, interesting, and thought-provoking question — one that implicitly contributes to the experience of the community rather than merely passively demanding knowledge from others.

Please read that guide before posting any non-sense.

siddhant3s 1,429 Practically a Posting Shark

Now this is an interesting case of ignorance.
But first, I must give OP the answer:
Look at the definition of atoi. It wants a cstring. Which is a null-terminated character array. Tell me, are you giving it a null terminated character array? No you aren't. You are giving him just a pointer to char. The output would be machine dependent. It was just your luck that the address just next to q and a have the value zero in your memory. So change your program as this:

#include<iostream>
#include<cstdlib>//<stdio.h> for old compiler
#include<cstring>//<string.h> for old compiler
using namespace std; //remove this line for old compiler
int main()
{
char a[5],q[5];//this will support only upto 4 digits
cout<<"Enter a char\n";
cin>>a;
strcpy(q,a);
cout<<atoi(a)<<",";
cout<<atoi(q);
return 0;
}

---------------------------------------------------------
Now. The funny part. I was pretty much sure that Ancient got the output correct because his complier had laid the memory in a different way. While the OP's Compiler used heap storage, q had a greater address than a (greater means had more value). Hence, when OP said cout<<atoi(&a), he got the output 2 (if the input was 2, say) because the next block of memory had zero value. But when he said cout<<atoi(&q), he got the value 22 because the next block was not zero but had the value 2 ( this block was the variable a itself). The memory representation was like this:

.
.
q:   |  2  |  <-- 0x000015 
a:   |  2 …
Ancient Dragon commented: Great explanaton :) +36
tux4life commented: Agreed with Ancient Dragon :) +7
siddhant3s 1,429 Practically a Posting Shark

int a = ((int-1) * x; I suppose you meant int a = ((int)-1) * x; assert(a == -5); // Assert fails!!!!!
I suppose you meant assert(b == -5); // Assert fails!!!!!

From TCPL K&R 2nd ed, if either operand of an arithmetic operation is unsigned int, the other is also converted to unsigned int and the result is also an unsigned int. (I'm only assuming the case where both are same width, e.g. unsigned int against signed int).

consider int b = ((int)-1) * x / 2; which is actually int b =( ((int)-1) * x )/ 2; if you care for the left associativity of the multiplication operator.
((int)-1) yields a integer -1 (note that this cast is useless). Since it is being multiplied by a unsigned int, -1 is promoted to a unsigned int. Any negative int when promoted to int will yield smallest non-negative value that is congruent to that integer, modulo one more than the largest value that can be represented in the unsigned type. So it is a very large number(4294967286 on my machine)which when multiplied by 10 yields larger number which is again demoted to fit into a unsigned int. Now you divide that number by two and you get the result.(which is still a larger number)(2147483643 on my machine.
The funny part is: all this doesn't happens in the line previous to this. That is perhaps because of your compiler's smartness, it doesn't promote -1 to int …

siddhant3s 1,429 Practically a Posting Shark

>Arw: Click Here
What if someone doesn't have a Flash Player. He won't fail LOL.
This happened to me while I was viewing it on Lynx(Text based web browser)
Anyways. Quite nice link.

siddhant3s 1,429 Practically a Posting Shark

>I wonder why some schools still insist on using Turbo when everyone in real life
>know that it's a crappy-nonstandard-outdated compiler.
>Can someone please explain?
It is called the we-first-teach-students-basic-and-then-move-to-advanced-compiler philosophy but they often forgets that it is very hard for students to quite that crap.
Or may be they want to realize the student how much crap that compiler is and then make them switch to heaven.

>I mean Code::block and Visual Studio are free!
Linux is also free but you see M$ Operating system around <noflame> those are also no less than crap </noflame>.

Visual Studio is not free. It is just that it is zero-cost. Free means this

siddhant3s 1,429 Practically a Posting Shark

>>EDIT: ALSO USE CODE-TAGS
You can use the noparse tag to tell him that. Use them like this

[noparse] every thing you write here will not be parsed even the [code] [/code] tags [/noparse]

Sky Diploma commented: Thanks :) +3
siddhant3s 1,429 Practically a Posting Shark

>How do you pass a structure array to another class?
Same way you pass arrays of integers:

using std::cout;
struct Points {
int xCoordinate;
int yCoordinate;
int zCoordinate;
} point[150];
void display_points(point arr[], int size)
{
//displays all the points
  for(int i=0; i<size;++i)  
      cout<<point_arr[i].xCoordinate<<","<<
              <<point_arr[i].yCoordinate<<","<<
              <<point_arr[i].zCoordinate<<"\n";
}
siddhant3s 1,429 Practically a Posting Shark

Consider a map of pair std::map<keyType, std::pair<int,int> > theMap; The solution is more or less like post#8 but pair would be more efficient.

siddhant3s 1,429 Practically a Posting Shark

cool thanx, could you please show me a link to some code? ive pretty new to containers and cant find any examples relating to lists of classes

[humor]
Yeah sure, why not. imthwee is quite good at it. ;)
[/humor]

siddhant3s 1,429 Practically a Posting Shark

QT Creator, as ArkM said, is optional. Just like GLADE for GTK+. And it is no-where VB-like. When we say a thing X is Y-like, usually Y is the pioneer and X has inherited from it. This is not the case with VB.

>I have every single source code file of the windows API, provided by Dev-Cpp
>under the Open Source lisence.
The file you posted is the definition my dear, not the implementation file. Implementation file comes compiled from the OS provider(M$) and thus you won't find its source code.
BloodShed Dev- Has provided you with the definition file so that you can see what all interface is available to you.

>What if everybody didn't know how to hard code, and always used QT?
>Nobody would actually know how to use C++ in its native form, only being
>able to code with help from a program that provides indirect functionality.
Fine, then stop using the STL. Stop using the windows.h and program everything yourself. Stop using the compiler, hard code yourself. Stop using your OS, hard code yourself. Would you?
Look, if your with hard coding, open-source toolkit will provide better control.
I used GTK+ in which I usually had to hard-code( Though, I never felt I was hard coding) while I was making a C app. Here is a Hello World:
[I realized that posting the code would make the thread bloated so here is the link for …

killdude69 commented: Passive aggressive. Not useful. Is not an oppinion, it is a statment to slander ones oppinion. You should have learned that everyone has their own oppinion in kindergarden. +0
tux4life commented: Very good post siddhant3s ! +7
siddhant3s 1,429 Practically a Posting Shark

>siddhant3s, you don't have to take a strike at my integrity just because you don't
>like my approach.
"strike at my integrity"..... what does that means? I never 'stroked' at your integrity.
Your approach? Which approach?
>GUI programs dont use the std:: namespace, because that is designed for
>DOS output like cin and cout.
I thought toolkits don't use std namespace so that they won't clash with the names with those of std ( which is exactly why namespaces are invented).
Also, std is not designed for command-line output. It is implemented to contain the standard names.


>WinAPI is the most commonly used and best documented API there is.
I can bet you would find more documentation for QT and GTK+. Naturally, M$ cannot compete us( the open-source hackers community). So, you would never find as much quality docs as you would for an opensource toolkit.

>Just because of a few compromises doesn't mean it has to be taken out of the >equation completely.
You call non-portability a minor compromise? I would never use a proprietary toolkit and become a slave of a private firm.

>Also, with QT (like another suggested) you dont really code it yourself, its
>approach is completely indirect.
I don't code? Then who do? And its approach is perfectly fine. It is open-source. You can proceed further development of QT itself; can you proceed the development of any WinAPI yourself? …

siddhant3s 1,429 Practically a Posting Shark

>If you are programming in windows, you would use the Windows Application >Programming Interface (WinAPI).
And always get struck with windows and make unportable GUIs. Well, there is a very cute library which is called wxWidget. Learn it. It will save you time as it is portable, so would not have to learn a new toolkit when porting your application to other platform.
Even QT and GTK+(which comes with the binding gtkmm for c++) are good alternative.
But please don't settle with windows MFC or any other platform-dependent toolkit.

The beauty of wxWidget is that it uses the native API for the particular platform: like WinAPI when in Windows, GTK+ when in Linux GNOME, QT when in Linux KDE. So, you always get the native feel.

siddhant3s 1,429 Practically a Posting Shark

Well, you should perhaps try to allocate +1 byte while using new: char* file_name=new (nothrow) char[str.length()+1]; You know why!! don't you?

siddhant3s 1,429 Practically a Posting Shark

Oh man! Did anyone told you that you should have been using the post tags:

[code=cplusplus] //paste the code here

[/code]

Anyways, your code is awful. I am sure you would be programming in a Old-style compiler (perhaps TC++ ). Read this:http://cppdb.blogspot.com/2008/10/why-you-shouldnt-use-you-use-old-c.html
You have not coded the main() function yet.

[Please, anyone, who can explain him what is wrong with his code. I am too frustrated to do so. And yes, please do so before 6th June. LOL ;)]

siddhant3s 1,429 Practically a Posting Shark

>USE AN ARRAY!
One of the baddest advice that can be given to a beginner.
Don't you know that arrays are evil?
>efficiency before sophistication.
Err. The better way to saying is : 'Clarity before efficiency".
As Donald Knuth puts up very beautifully:"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil."

Besides, you should ``show" the user the ``path" rather than showing him just the direction-posts.

Ancient Dragon commented: Excellent :) +36
tux4life commented: Excellent! +7
siddhant3s 1,429 Practically a Posting Shark

Or perhaps use vectors of pair of string and double.

#include<utility>
#include<vector>
#include<string>
int main()
{
std::vector<std::pair<std::string,double> > Foo;
Foo.push_back( pair("Sally",1021) );
Foo.push_back( pair("John",3.14021) );
std::cout<<"Name:" <<Foo[1].first<<"  GPA:"<<Foo[1].second;
}
iamthwee commented: Please consider indenting your code and use of whitespace kiddo. -4
Salem commented: Negate more of 'iamthepiss' pendantry. +33
siddhant3s 1,429 Practically a Posting Shark

For those who suggested the OP:
The OP definitely has been given this problem as a homework by his instructor. The instructor wants OP to be able to tell and understand how looping works in programming. Hence, actually running the program would be a sought of 'cheat'.
I am sure the instructor would have given a note: "Do not use the compiler to solve this problem", but even if he didn't, it would be best to the benefit of the OP, to first understand the predict the answer and then check the answer.

siddhant3s 1,429 Practically a Posting Shark

Yes you can. More simply than you can imagine.
The only problem is that you shouldn't be playing with the null character '\0'.

string answer1 = "anything that has mass and occupies space";
string userresponse1;
cout << "1. Define matter.\n";
getline(cin,userresponse1);//<<<<<See the difference
if (userresponse1 == answer1)
{
cout << "Correct" << endl;
score += 1;
}
else
{
cout << "Incorrect" << endl;
}

The moral is, use getline when you know that the user response will include spaces.

Always post your code in the code tags:

[code=cplusplus] //your code goes here

[/code]

siddhant3s 1,429 Practically a Posting Shark

When you implement .eof(), things doesn't often work they way you think it does.
The problem is not in the .eof but in your usage of eof().
Read this thread on Stack Overflow, wherein the OP faces exactly similar problem. The first answer(in green) has brilliant explanation regarding this.

siddhant3s 1,429 Practically a Posting Shark

No, you cannot assign the return type of getline to a string.

I didn't notice the commas on the ends of each line though I suppose even without them you could just modify the final getline call to have no delimiter.

In any case a: getline( infile, string, ',' ); where string is the attribute you want to read in, will suffice.
And if you didn't have commas on the end when you read in the last attribute you would simply do the same as above but without specifying a delimiter.

Of course, you cannot assign it to a string. (see my post). But I was emphasizing on the point that you don't need to read a whole line and then parse it. Instead you can just put the the comma as the third argument.

siddhant3s 1,429 Practically a Posting Shark

Use the substr function to print a subscript.
In your case, it will work as: std::cout<<r.substr(0,2);

siddhant3s 1,429 Practically a Posting Shark

Yes, that line is having the exact problem.
change infile >> songs[counter].bandName = getline(infile, line, ','); to getline(infile, songs[counter].bandName, ','); And similarly for each .songName and .duration
Why?
As your files are comma-separated, there is no point in using the input operator >> . This operator will fetch only a 'word' (word means a string which is delimited by a white-space).

>So, what you need to do is to read in the entire line (i.e. specify no delimiter as
>it
>will default to the newline character). Then the variable 'line' will contain the
>entire line with the commas and all you need to do is split it.
No. He is doing it rightly. As the file is comma-separated, he don't have to parse every single line(that is one advantage by maintaining the uniform syntax). He just need to earase the infile>> from all those lines.

siddhant3s 1,429 Practically a Posting Shark

>how can I be more clear. you dont learn if you dont ask questions.
You learn more when you read a book and then ask questions.

>I have not attempted to write the parts I am asking about because I wanted to
>hear a better way of doing it before I went & wrote the thing to find out there is
>a better way.
So you want short-cuts. To be a good programmer, you need to practice. Until you go wrong and dig the problem yourself, you won't able to be a good programmer.

Smooth Roads don't make winners

Applies the most to programming.

>But thank you for the link
But I am afraid you did not read it properly( this is reflected in your last post)

>So far this is what I have although the open file is not working & I am strugling
>to store the information i need in arrays. Any advice?
Yes, an advice. There is no point in hitting and trying when you don't know the concept behind what you are doing. My advice is: buy a decent book about programming (the best is Accelerated C++) or read some free books/tutorial online (the best book would be Thinking In C++ by Bruce Eckel which is both free and fantastic) and then try out. Had you read the books before, you wouldn't be asking such questions because they teach you all this in …