6,741 Posted Topics

Member Avatar for Suraine

>how can i achieve to have the program to randomly choose a number from 0 - 27? [code=cplusplus] #include <cstdlib> #include <ctime> #include <iostream> int main() { std::srand ( (unsigned)std::time ( 0 ) ); int r = rand() % 28; std::cout<< r <<'\n'; } [/code] Further details can be found …

Member Avatar for Suraine
0
253
Member Avatar for bis student

Why not use an enum for the blood type instead? That way you don't have to validate a random string.

Member Avatar for Luckychap
0
140
Member Avatar for Adrian99420

>Can any pro fren show me the function to code it? I imagine it would be something like this: [code=cplusplus] void button_Click ( Object^, System::EventArgs^ ) { tabControl->TabPages->Add ( gcnew TabPage ( "Dynamic Tab" ) ); } [/code]

Member Avatar for Narue
0
105
Member Avatar for tlly

When you need it, you'll have your answers. >But why not declare the variable we need to the appropriate type >during programming time rather than downcasting it at run time? Because that might not be practical. Consider an array of base class pointers with varying dynamic types down the hierarchy, …

Member Avatar for Ancient Dragon
0
358
Member Avatar for Jacky1
Member Avatar for bigbadowl

1) You have several options. Here are a few: [LIST] [*]Create your own case insensitive traits class and apply that to your strings. [*]Convert all of your strings to one case before doing comparisons. [*]Forget about the string specific search member functions and use STL-based searching where you can provide …

Member Avatar for ivailosp
0
117
Member Avatar for LadyPersia

>I've been stuck here for a while now... So basically you don't know how to calculate a prime number?

Member Avatar for jephthah
0
972
Member Avatar for Arne Kristoffer

>How do i read the lines of an file into an vector? [code=cplusplus] #include <fstream> #include <iostream> #include <string> #include <vector> int main() { std::ifstream in ( "myfile" ); if ( in ) { std::vector<std::string> lines; std::string line; while ( std::getline ( in, line ) ) lines.push_back ( line ); …

Member Avatar for Narue
0
77
Member Avatar for Hodson

>I haven't been able to find much on the internet about it. It's really nothing more than a bucket sort where each bucket holds a count for each number on the range: [code=c] #include <stdlib.h> int pigeonhole_sort ( int a[], int n, /* Array and size of the array */ …

Member Avatar for Hodson
0
325
Member Avatar for Nemoticchigga
Re: enum

>Does anyone know the size of an enum? [code=cplusplus] std::cout<< sizeof ( foo ) <<'\n'; [/code] >is that 1 byte, but if i had 10 enumerations would that be 2 bytes, and so on? The number of constants doesn't change the size of the enum.

Member Avatar for Narue
0
118
Member Avatar for amt_muk

strtol offers more error handling capability and is safer. atol is easier to use, but is impossible to properly check for errors and exhibits undefined behavior for some erroneous input. The basic difference is that you should use strtol unless your string has already been carefully validated and you're 100% …

Member Avatar for amt_muk
0
437
Member Avatar for Spaiz

>is there a way to build a website with C? You can write CGI in C, if you really want to. But it's not really worth it as CGI tends to focus on the very thing that C is poor at: string manipulation.

Member Avatar for jephthah
0
58
Member Avatar for fatima_almahdi

This isn't a chat room, please at least try to use proper spelling, grammar, and punctuation. >1_o(n log n) >2-o(n) Both examples (assuming I'm reading your poorly indented and thought out pseudo code correctly) are O(N^2).

Member Avatar for sarehu
0
89
Member Avatar for mostafa mahmoud

>but i didnt write that it is an online project Hmm? It sure looks like you did: [quote=mostafa mahmoud] Please guide me how to make such an online project in C++. [/quote]

Member Avatar for Narue
0
103
Member Avatar for jasonlys

>How do you exactly put the friend function into this program? What friend function? The syntax looks like this: [code=cplusplus] #include <iostream> class Test { int i; public: Test ( int init ) : i ( init ) {} friend void display ( const Test& test ); }; void display …

Member Avatar for Narue
0
87
Member Avatar for Taker

You forgot to ask your question. Also, if you want us to be able to compile the code, you'll have to include the contents of node.h.

Member Avatar for Taker
0
186
Member Avatar for edek

Do some research on pipes. Your system likely has a function you can call from C (popen, or similar) for opening a pipe based stream. Or, if you don't need access to the output from B, you can use the equivalent command line piping with the system function: [code=c] system …

Member Avatar for Salem
0
86
Member Avatar for Swift7625

So your compiler supports long long, but no way to format it into a string? I find that hard to believe, did you check your compiler's documentation? At the very least there should be a non-standard function or extension that supports what you want.

Member Avatar for Salem
0
429
Member Avatar for missileh

>I came across a new site "<snipped link>" You "came across" it, huh? :icon_rolleyes: In my experience, that's a lie. It's much more likely that you're somehow affiliated with the site and are trying to advertise it without looking like a spammer.

Member Avatar for jephthah
0
143
Member Avatar for johnnygaddar

>If you can use the source below and guide me what I should do next. Basically you haven't done anything, but you seem to understand the problem well enough. What you need to do is figure out how to add a new node at the correct position (as far to …

Member Avatar for johnnygaddar
0
181
Member Avatar for lorentz

>Here you are Somehow I don't think that's the problem, Ramy. >I have a little problem with resizeing my program for different screen resolutions. Do you mean that when the resolution is changed, your UI looks like crap? If so, the easiest solution is to use anchoring and resizing of …

Member Avatar for Narue
0
142
Member Avatar for RatherBeInVegas

>you could use rand in time.h rand is declared in stdlib.h, or for C++, cstdlib. >Where can I find examples of this used in the manner you are describing? [code=cplusplus] #include <cstdlib> #include <ctime> #include <iostream> // Trick for getting the number of // items in an array of T …

Member Avatar for RatherBeInVegas
0
188
Member Avatar for Kaushalya

The only way is to escape the backslash. C++ doesn't support verbatim strings like C#.

Member Avatar for chiwawa10
0
88
Member Avatar for Reg74

1) Functions don't nest (you can't define buildListForward inside main. 2) You can't use a type that doesn't exist (you haven't defined nodeType). 3) Check your spelling. C++ is case sensitive and very picky about syntax. 4) If you say you're going to return a value from a function, do …

Member Avatar for Narue
0
1K
Member Avatar for theausum

So far all of your posts consist of short, pointless, broad questions such as this. It suggests that you're spamming simply to advertise your signature and have no interest in the replies. I recommend you take a step back and think about how your threads look, or you'll end up …

Member Avatar for Narue
0
89
Member Avatar for coolerli

>I really hope that is a typo and you meant: "solveD it already".... As do I. It takes some big rocks to demand such a thing when you have three post and no discernible reputation in the community. Anyway, in either case, it would be useful to know the answer. …

Member Avatar for Narue
0
75
Member Avatar for Maulth

I started writing out all kinds of suggestions on the assumption that you hadn't done anything and weren't sure about how to begin. However, it struck me that you may have a lot of this already written and want help with the MySQL access and server upload. So what have …

Member Avatar for Maulth
0
164
Member Avatar for Drake

You never call the function, you just redeclare it. To call a function you use the name and replace parameters with actual values. For example, here's how you might call each of the functions: [code=cplusplus] func1(); func2 ( 1.0, 2.0 ); func3 ( V, R ); func4 ( I, R …

Member Avatar for Narue
0
144
Member Avatar for InfinityArc

1) Only if you plan on giving users of the class the ability to change the boolean directly. 2) Parse error, please try again.

Member Avatar for InfinityArc
0
156
Member Avatar for Luckychap

>I need to understand the concept of inheritance in Oops. >Can any one explain with real life example the use of inheritence to enhance a super class. >It will be very helfull to me if you can explain me the use of inheritence to build a simple car. It's actually …

Member Avatar for chiwawa10
0
123
Member Avatar for infernojmd

Here's a method that definitely can't be turned in as homework: [code=cplusplus] #include <iostream> #include <locale> #include <string> template <typename CharT> class numfmt: public std::numpunct<CharT> { CharT _thousands_sep; int _grouping; public: numfmt ( CharT thousands_sep, int grouping ) : _thousands_sep ( thousands_sep ), _grouping ( grouping ) {} private: CharT …

Member Avatar for Lerner
0
108
Member Avatar for bhoot_jb

You'd probably find [URL="http://www.codeblocks.org/downloads/5"]Code::Blocks[/URL] to be the easiest trial. It comes with a Windows port of GCC. Downloading and installing GCC manually can be a chore if you're not used to such things.

Member Avatar for bhoot_jb
0
124
Member Avatar for 11moshiko11

>how can i transfer the address of "gradeTemp" to "numGrades"? Return and assign: [code=cplusplus] Grade **AddGrade(Grade ** _numGrades,int& _students) { // ... return _numGrades; } //... numGrades = AddGrade ( _numGrades, students ); [/code] However, that still doesn't change the fact that as soon as you overwrite numGrades, you've created …

Member Avatar for dougy83
0
83
Member Avatar for wollacott

A string is basically just an array, why can't you simply start an index at the end and count down?

Member Avatar for Aia
0
121
Member Avatar for ritasha

Just get a random number between 0 and the number of sides on the die: [ICODE]rand() % sides[/ICODE]. There's no complex logic involved.

Member Avatar for jwenting
0
84
Member Avatar for man4ish

>but problem is this it is too lengthy It's not that long. But at a glance it looks like you have a lot of repeated code that can be moved to a function. Also, indent your code and put it in code tags. Seriously, what you posted is so difficult …

Member Avatar for Salem
0
154
Member Avatar for aminit

>Can anyone give me a simple idea how to remove the duplicated letters in a text Can you be more specific? Should the two L's be removed in "SLOWLY"? If so, which L should be removed? Are the characters to be ordered in any special way? All of these play …

Member Avatar for aminit
0
118
Member Avatar for Suraine

Well clearly the flux capacitor is overloading the compiler, accelerating your CPU to 88 miles per hour and sending part of your line to 1955. Give it about two hours for the line to find its way back and you'll find that most of the bugs in your program are …

Member Avatar for Suraine
0
105
Member Avatar for wollacott
Member Avatar for Jennifer84

>Is it possible to find the variablename from Numbers[0] wich is Number2 ? Not easily, no. The variable name is a symbol that's not available at runtime unless you store it as a string in memory. Perhaps I can give a more helpful answer if you explain what problem you're …

Member Avatar for Jennifer84
0
259
Member Avatar for programmer321
Member Avatar for programmer321
0
151
Member Avatar for leverin4

>How can I fix it so it outputs the date entered by the user when there is an error? You're printing the value of the date itself in your error message. At that point, the date has already been checked, errored, and set to the default. Unfortunately, I can't tell …

Member Avatar for Lerner
0
130
Member Avatar for demroth
Member Avatar for demroth
0
154
Member Avatar for daviddoria

>Is this possible? Yes, but it's not the most brilliant of ideas. What exactly are you trying to do that prompted this question?

Member Avatar for daviddoria
0
291
Member Avatar for GPXtC02

>is there a built in function to deal with numbers similar to how the swap member function Yes, include <algorithm> and you can use the std::swap template function as AD has shown.

Member Avatar for GPXtC02
0
262
Member Avatar for tootypegs

>everytime it writes to my file it overwrites the previous data stored with in it It sounds like you keep closing and opening the file with the ios::out mode. In write mode, the newly opened file is truncated to zero length. You can avoid that by using ios::app (as you …

Member Avatar for tootypegs
0
116
Member Avatar for legendarya49

>the segmentation fault is in the merge sort but i can tfind out how to fix it A segmentation fault means you accessed memory beyond your boundaries. If you're using a pointer it likely means the value of the pointer is incorrect. If you're using array indexing, it likely means …

Member Avatar for legendarya49
0
144
Member Avatar for dv1r

Once you open the stream, it's basically the same as working with stdin and stdout. What problems are you having with your code?

Member Avatar for dv1r
0
130
Member Avatar for vaid.abhishek

>I want middle [Iterator type ] to be static And what are you expecting this kind of optimization to buy you?

Member Avatar for vaid.abhishek
0
140
Member Avatar for Troula

1) You can close and re-open a file stream, but if you read the previously opened stream to end-of-file or there was an error, you need to clear the stream state: [code=cplusplus] #include <fstream> #include <iostream> void read_stream ( std::istream& in ) { char ch; while ( in.get ( ch …

Member Avatar for Narue
0
111

The End.