518 Posted Topics

Member Avatar for rajboy

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 …

Member Avatar for ithelp
0
100
Member Avatar for san gabriel

Well, why are you not using std::strings? I wrote a quick code with those. It is quite flexible: [code=cplusplus]#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( …

Member Avatar for siddhant3s
0
167
Member Avatar for clutchkiller

>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 …

Member Avatar for ArkM
0
146
Member Avatar for Curtain51

Why are you not using [URL="http://www.cplusplus.com/reference/stl/vector/pop_back/"]vector::pop_back[/URL] ? [code=cplusplus] 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; …

Member Avatar for Curtain51
0
127
Member Avatar for sharkattack85

>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.

Member Avatar for siddhant3s
0
247
Member Avatar for DayOldPorridge

Yes. First you need to learn the Basic HTTP protocol. Here([url]http://www.jmarshall.com/easy/http/[/url]) is excellent tutorial for the same. It teaches the protocol by using telnet. Then you should learn about sockets ([url]http://docs.python.org/library/socket.html)[/url]. Also, read the Beej's Network Programming Tutorial ([url]http://beej.us/guide/bgnet/[/url]) it would be helpful, although it is intended for C programmers. …

Member Avatar for siddhant3s
0
99
Member Avatar for CppFTW

>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: [url]http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.7[/url] and [url]http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.16[/url] Anyways, Good Catch

Member Avatar for CppFTW
0
146
Member Avatar for Ray Gray

[ICODE]int a = ((int-1) * x;[/ICODE] [INDENT]I suppose you meant [ICODE]int a = ((int)-1) * x;[/ICODE] [/INDENT] [ICODE]assert(a == -5);[/ICODE] // Assert fails!!!!! [INDENT]I suppose you meant [ICODE]assert(b == -5);[/ICODE] // Assert fails!!!!![/INDENT] [QUOTE]From TCPL K&R 2nd ed, if either operand of an arithmetic operation is unsigned int, the other …

Member Avatar for ArkM
1
104
Member Avatar for gplkrsna

Create a file with all junk upto a maximum size: [code] 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 …

Member Avatar for csurfer
0
100
Member Avatar for Aggresive_Mind

>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.

Member Avatar for Salem
0
138
Member Avatar for kaio-ken

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 …

Member Avatar for pwl
0
124
Member Avatar for aarifameen

>>is that the ans of my question? Let me make you one thing clear. This is what Eric. S Raymond said on his article "[URL="http://www.catb.org/~esr/faqs/smart-questions.html"]How to ask question the smart way[/URL]" [QUOTE=Eric Raymond]Never assume you are entitled to an answer. You are not; you aren't, after all, paying for the …

Member Avatar for siddhant3s
-1
126
Member Avatar for daino

>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 …

Member Avatar for Prabakar
0
275
Member Avatar for TheBattlizer

>How do you pass a structure array to another class? Same way you pass arrays of integers: [code=cplusplus] 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"; } [/code]

Member Avatar for TheBattlizer
0
142
Member Avatar for blahblah619

>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.

Member Avatar for siddhant3s
0
234
Member Avatar for nhamyl

>>EDIT: ALSO USE CODE-TAGS You can use the noparse tag to tell him that. Use them like this [noparse] [noparse] every thing you write here will not be parsed even the [code] [/code] tags [/noparse][/noparse]

Member Avatar for siddhant3s
0
88
Member Avatar for Usura

[QUOTE=Usura;880881]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[/QUOTE] [humor] Yeah sure, why not. imthwee is quite good at it. ;) [/humor]

Member Avatar for siddhant3s
0
187
Member Avatar for ttqtrang146

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

Member Avatar for ttqtrang146
0
132
Member Avatar for SallyJ
Re: Loop

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 …

Member Avatar for jesseb07
0
149
Member Avatar for ithelp

[QUOTE]All vibration ceases at Zero Kelvin; All 'things' are made of matter; All matter is made up of particles that vibrate; therefore All 'things' that do not vibrate either Do not exist or exist at Zero Kelvin. [/QUOTE] Wrong!!. You are only considering classical phenomena but quantum mechanics has more …

Member Avatar for GrimJack
0
310
Member Avatar for touqra

Or perhaps use vectors of [URL="http://www.cplusplus.com/reference/std/utility/pair/"]pair[/URL] of string and double. [code=cplusplus] #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; } [/code]

Member Avatar for siddhant3s
0
115
Member Avatar for theashman88

Yes you can. More simply than you can imagine. The only problem is that you shouldn't be playing with the null character '\0'. [code=cplusplus] 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 …

Member Avatar for theashman88
0
83
Member Avatar for FaMu

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 [URL="http://stackoverflow.com/questions/21647/c-reading-from-text-file-until-eof-repeats-last-line"]this thread[/URL] on Stack Overflow, wherein the OP faces exactly similar problem. The first answer(in green) has brilliant explanation regarding this.

Member Avatar for FaMu
0
167
Member Avatar for Brandon515

Use the [URL="http://www.cppreference.com/wiki/string/substr"]substr[/URL] function to print a subscript. In your case, it will work as: [icode]std::cout<<r.substr(0,2);[/icode]

Member Avatar for Brandon515
0
115
Member Avatar for ss20090612

A new-comer should be directed to Python. It is real and it is fun. I have never seen a powerful yet easy language like this. One can almost learn the basic in a weekend. 1.Go to [url]http://python.org/[/url] 2. Download Python for you platform (most GNU/Linux Distros have it pre-installed) 3. …

Member Avatar for kenji
0
289
Member Avatar for shuda009

Yes, that line is having the exact problem. change [icode]infile >> songs[counter].bandName = getline(infile, line, ',');[/icode] to [icode]getline(infile, songs[counter].bandName, ',');[/icode] 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 …

Member Avatar for Stinomus
0
1K
Member Avatar for gretty

Your work doesn't impressed me: >How do you open a text file in C++? >What function do you use to store a piece of text from the text file as an array/string. Did you bothered to open your text book or open a search engine and search it? [URL="http://www.catb.org/~esr/faqs/smart-questions.html#rtfm"]RTFM[/URL] and[URL="http://www.catb.org/~esr/faqs/smart-questions.html#rtfm"] …

Member Avatar for Raven6666
0
313
Member Avatar for Stefano Mtangoo

Find your answer by Searching the web: here is a pointer to a good thread which is very near to yours [url]http://groups.google.com/group/comp.lang.c++/browse_thread/thread/1a4b427d09b3eb77[/url]

Member Avatar for Stinomus
0
96
Member Avatar for timb89

Do the following: 1.Make a new node [I]temp[/I] and store x in temp->info. 2.Set temp->link = here->link 3.Set here->link = temp Thats it As you might have suspected, you don't require [I]first[/I] as an argument, hence the definition of insert should loop like: [icode]void insert(node *here, int x) [/icode]

Member Avatar for siddhant3s
0
72
Member Avatar for Se7Olutionyg

cin >> *h_ptr >> colon >> *m_ptr >> colon >> *s_ptr; This statement is wrong. Tell your user to separate hours, minutes, second by spaces (Like this : "5 15 30") and remove the colon [icode]cin >> *h_ptr >> *m_ptr >> *s_ptr;[/icode] If you want the user to be able …

Member Avatar for tux4life
0
108
Member Avatar for zack.walters

[code]cout << "Are there anymore student grades to enter? (y/n)" <<endl; [COLOR="Red"]{[/COLOR] cin >> inputDone; }[/code] remove the red bracket in your code.

Member Avatar for yun
0
147
Member Avatar for massivefermion

>I'm pretty sure everybody is an idiot and most of the time most people don't >know what they're talking about. I don't think so. Most of the time I [I]know[/I] what I am talking about. It is just that very rarely (usually when there is an emotional pressure) I speak …

Member Avatar for siddhant3s
0
188
Member Avatar for tonig_ccc

Wow, I really like kid playing with men's tools. So you want to become a cracker? Good Good. Didn't your mother told you that cracking isn't sexy? In my advice, be a hacker. Read : [URL="http://www.catb.org/~esr/faqs/hacker-howto.html"]How to become a Hacker[/URL]

Member Avatar for siddhant3s
0
134
Member Avatar for nanchuangyeyu

short usually 2 bytes, So in your case the 3d array Matrix has size of 2 X 6 X 400 X 400 = 1920000 bytes = 1.83 Mega Bytes. Don't you think it is much? If your program is using this much of memory, ask yourself " Do I really …

Member Avatar for ArkM
0
212
Member Avatar for phoenix911

A little mathematics can do the magic. The sum of consecutive integers from [tex]n_1[/tex] to [tex]n_2[/tex] (including both [tex]n_1[/tex] and [tex]n_2[/tex]) is given by: [tex]sum=n_2(n_2+1)-n_1(n_1-1) \over 2[/tex] (If you need a proof(which is quite trivial), let me know) Hence the problem now remains to run a nested loop with iterators …

Member Avatar for siddhant3s
1
202
Member Avatar for SallyJ

>It serves the same purpose as endl Not likely. There is a difference between std::endl and \n. (To the OP: The following explanation may not suited for you. The answer of your question was well given in the posts above) To understand lets see what happens you do a cout. …

Member Avatar for siddhant3s
0
6K
Member Avatar for yairzick

First of all let me simplify your code (and remove unnesasarily added inheritence): So now, have a look at the snippet below [code=cpp] #include<iostream> template<typename T> class tc{};//a template class class Base{};//a base class class Derived : public Base { void der_fct(); /* ... */ };//a derived class int main() …

Member Avatar for siddhant3s
0
93
Member Avatar for still_learning

Start with two coordinates. It is trivial that the position of the store in this case would be the mid point of the line joining the two coordinate. Now start with three coordinates. The most suitable location in this case would be a point from which, all the three points …

Member Avatar for siddhant3s
0
156
Member Avatar for Topi Ojala

You should perhaps look laws governing the trajectories. I am not going to derive them here (although proof is trivial from Newtons Equation of Motion) but am listing the paramatarized (wrt time) equations governing projectiles. [tex]x=v_0\times cos(\theta) \times t\[/tex] and [tex]y=(v_{0}\times sin(\theta) \times t) - (\frac{1}{2}\times g\times t^2)[/tex] where [tex]v_0[/tex] …

Member Avatar for amrith92
0
288
Member Avatar for dweller

Tux, you should also tell him to place the conditional compilation preprocesor directive so that his files are not included more than once: [code] #ifdef MYHEADER_H #define MYHEADER_H //content of the files #endif [/code] This will make sure that this header file will be included only once even if you …

Member Avatar for dweller
0
185
Member Avatar for Majestics

I think you should use the [URL="http://cimg.sourceforge.net/"]CImg Library[/URL]. Also note that I found it easily by using a search engine like [url]www.google.com[/url] Always STFW before posting a query.

Member Avatar for MosaicFuneral
0
137
Member Avatar for haven_u

Implementation looks pretty fine. Post the declaration too. BTW, the declaration should be [code=cpp]class student{ public: student(); ~student(); //other stuff }[/code]

Member Avatar for haven_u
0
129
Member Avatar for cruisx

>>Nope, I can compile it using the newest MinGW compiler Wow! I am fully impressed, I will give you 500 points for this. But, being silent, knowingly that OP is moving toward non-portable code should not be practiced by (a portability fan like) you. The OP should be aware that …

Member Avatar for amrith92
0
149
Member Avatar for firehazrd0

As you are, new, I should rather clarify what Narue meant to say. Look at Line 7. That is the declaration of the function (formally this is called a prototype of a function). It tells the compiler "Hey, if you get a call for this function, assume that I am …

Member Avatar for firehazrd0
-1
103
Member Avatar for jesseb07

Everyone who starts using template eventually get struck on this question. Read this for decent answer :[url]http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12[/url] If you are still confused (iff only after reading the above link), get back to us. But do read it completely.

Member Avatar for jesseb07
0
131
Member Avatar for 35nando

>>All of a sudden, you could find it happens at some much more obvious and >>inconvenient point in the code (say save file). [QUOTE]Murphy's Law for Computer programming: A program with undefined behavior(or ill defined behavior) will continue to work in all debugging session and will halt when a extremely …

Member Avatar for neigyl_noval
0
322
Member Avatar for Aamit

>>but problem is how to make this dynamic?? What do you mean by dynamic? BTW, do you realize that the code which you have written is no where near to c++? This is a C code. And you participate in a C++ forum. No doubt you have a red dot …

Member Avatar for siddhant3s
0
502
Member Avatar for power_computer

>>From a very good programmer who is both fluent in c and c++ It is a sad part that beginners of the language are actually incapable of telling if a programmer is 'good' or 'bad'. A C guru is not necessarily a C++ guru and vice-versa. Perhaps, a major fraction …

Member Avatar for Salem
0
3K
Member Avatar for Usura

You have put the struct student as a private data member. Private members are not inherited. Use the protected specifier to inherit student in the class B. I am still not sure what you exactly want to accomplish. Can you show us by writing a function call in the main(). …

Member Avatar for r.stiltskin
0
100
Member Avatar for ganmo

[QUOTE=iamthwee;869143]Alternatively, [code]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; } }[/code][/QUOTE] What a Bull-!@#$ of code was that. Simply lost all purpose of find() To …

Member Avatar for ganmo
0
289

The End.