1,358 Posted Topics

Member Avatar for askhari139

That is an unusual notation, but it could work. That aside, this program won't run properly. Your b array is only 2 elements long. [B]Q.[/B] What happens if your user wants to generate a sequence that is greater than 2 numbers long? [B]A.[/B] Your program crashes.

Member Avatar for Fbody
0
121
Member Avatar for DGeneral

The extraction operator breaks the input stream at a whitespace (a 'space' or a newline, among others). Take advantage of that and try using multiple input statements:[CODE]while (ifstream >> rowNumVar) { ifstream >> wordVar >> floatValVar; }[/CODE]

Member Avatar for Fbody
0
9K
Member Avatar for Garrett2011

I'm not really sure what you're asking, but I think you're asking about the efficiency of passing conventions. In your example, if you were originally passing an 8-byte long and you change it to a 4-byte pointer it wouldn't make an 8-byte difference. It would only make a 4-byte difference, …

Member Avatar for TechnoCat
0
138
Member Avatar for themaestro

A word of advice, don't mark your thread with "URGENT" that actually makes it more likely to be ignored. It may be "URGENT!!!" for you, but it isn't for us. I'm not sure what you did, but I can't read your comment(s) well enough to help much. Did you try …

Member Avatar for themaestro
0
128
Member Avatar for awadojag

Um... How do you expect to add a number to the file if you never read a number? I don't see anything related to the "Enter Age: " prompt... Once you add the proper input statements, the rest is basically the same as for the name.

Member Avatar for Fbody
0
101
Member Avatar for slawson01

I would suggest you speak with your instructor and ask them this question. It seems to me that the purpose of this assignment is to demonstrate dangling pointers and the problems they cause because you did a shallow copy when a deep copy was required. I suspect the instructor wants …

Member Avatar for nbaztec
0
179
Member Avatar for Fbody

I'm doing some self-study concerning statistics right now and while doing so I want to get some practice with templated classes. As a result, I'm working on a collection of templated classes designed for statistical analysis. What I would like to know is how I would handle creating typedefs for …

Member Avatar for nbaztec
0
1K
Member Avatar for Nandomo

[QUOTE=Nandomo;1350308]I don't comprehend getche.[/QUOTE] The function getche() is a non-standard input function defined in the non-standard header "conio.h". Don't use it. Instead, use something standard like [URL="http://www.cplusplus.com/reference/iostream/istream/get/"]istream::get()[/URL] or similar. EDIT: Or do as first person suggested. Approach your problem directly instead of dancing around it.

Member Avatar for Nandomo
0
2K
Member Avatar for bigwhiteegg

On Line 100 you declare nd as a pointer to a Listnode, which is fine. Then you do nothing else with it until Line 107 where you try to dereference it to store information to the object it points to, which is definitely NOT fine. The problem is you haven't …

Member Avatar for bigwhiteegg
0
130
Member Avatar for lasl0w

[QUOTE][CODE]for (i=0; i<tempstr.length() ; i++){ if (tempstr[i] == ' ' && tempstr[i+1] == ' ') {[/CODE][/QUOTE] [B]Never[/B] use i+1 as an array index unless you account for it in your loop control. When your for loop gets to the last element of the array, you go past its boundaries with …

Member Avatar for lasl0w
0
111
Member Avatar for maharjun

I think you'll have to share a little more of your code so that we can see exactly what's going on. What do you initialize 'p' to? Are you initializing it to NULL or an actual object/value? The assignment operator should only call a constructor if you use a pass …

Member Avatar for mike_2000_17
0
1K
Member Avatar for baconswife

[URL="http://www.gidnetwork.com/b-38.html"]Your formatting isn't very good,[/URL] it makes it very difficult to follow what you are trying to do. What exactly is this program supposed to do? Why do you have assignments formatted like this?[CODE]found = 2 * a > b;[/CODE]What are you hoping this will accomplish?

Member Avatar for Fbody
0
123
Member Avatar for Duece_68

It's evaluated that way because of the mathematical order of operations. Look again.[CODE] //with this macro #define SQUARED(x) (x*x) //this line: int i = SQUARED(3 + 2) //literally becomes this int i = [COLOR="Green"][B]( 3 + 2 * 3 + 2)[/B][/COLOR]; //order of operations says multiplication occurs before addition int …

Member Avatar for arkoenig
0
151
Member Avatar for Rizwan606

There are a couple different ways to do it. Both will require loops. What are the even numbers? 0,2,4,6,8, etc... Can you think of a way to generate a similar series to use as a sequence of array indexes?

Member Avatar for Rizwan606
0
383
Member Avatar for jehdo

[URL="http://www.daniweb.com/forums/faq.php?faq=daniweb_policies"]You obviously didn't read the rules when you signed up.[/URL] [list=1][*]Don't hijack threads (especially 6-year old ones). [*][URL="http://www.daniweb.com/forums/announcement8-2.html"]You need to do your own homework.[/URL] [/list] You'll need nested loops to do this, but I'm not going to demonstrate until you try yourself.

Member Avatar for Fbody
0
603
Member Avatar for ashishchoure

Your Case 1 is not a "Perfectly valid Derived" it is a Base object that has been forced into a pointer to a Derived object. You can't call testD from a Base because a base has no [B]testD[/B] method, virtual or otherwise, it has a [B]test[/B] method. In fact, none …

Member Avatar for Fbody
0
123
Member Avatar for arkarjun

A solution to what exactly? Give us something to work with... Oh, and check [URL="http://www.daniweb.com/forums/announcement8-2.html"]here[/URL] as well.

Member Avatar for Fbody
-8
238
Member Avatar for brontok214

You need to start by initializing your "dist" array properly. Currently, it is not an array, and it is not initialized. It is a pointer to a single int. If you try to use it as an array, you will cause a segmentation fault at run time. To accomplish this, …

Member Avatar for Fbody
0
245
Member Avatar for ekailan

You'll have to elaborate a little. "It's not working" gives us nothing to go on. Are you getting a compiler error, invalid output, etc...? What is the definition of "AddString()"?

Member Avatar for ekailan
0
204
Member Avatar for Rayanjaha

By chance is this assignment related to inheritance? If so, it is possible to define 2 classes that work together to produce a shape such as a rectangle then determine the area.

Member Avatar for mrnutty
0
117
Member Avatar for MrJNV

You would have to read the file word-by-word and compare the read-in word with the user input to see if it matches. Alternatively, you could read the file (again, word-by-word) into a vector of strings, then use [URL="http://www.cplusplus.com/reference/algorithm/find/"]the find() function from the <algorithm> header[/URL].

Member Avatar for hag++
0
310
Member Avatar for kelvindata
Re: C++

[QUOTE=chepaii;1347112]Hi! can you make and run a program that will display the numbers and so on depending on the number of lines the user will enter. example if the value of N is 4 the output will be like this: N=4 4321 321 21 1 thanks ! :))[/QUOTE] :yawn: Wow, …

Member Avatar for kes166
-2
206
Member Avatar for myk45

I don't know if there are sites dedicated to any other specific types of algorithms, you will have to do some googling for that. That being saie, [URL="http://www.sorting-algorithms.com/"]sorting-algorithms.com[/URL] is one that I use for obvious reasons.

Member Avatar for Fbody
0
268
Member Avatar for hq1

[QUOTE=hq1;1344523]okay so im just guna work on the above assignment at school, but i have this other assignment that i did below, it reads from keyboard but i also need it to read from file, how do i do that? [code] The following program reads a number from the keyboard …

Member Avatar for Fbody
0
461
Member Avatar for mrickert

I don't see where you are inserting a '\0' (NULL char) to terminate the C-string. The '@' must be an extraneous character stored in a byte adjacent to the memory that holds the C-String.

Member Avatar for Fbody
0
126
Member Avatar for nolife

[QUOTE=caged_fire;1341996]Linker errors can be quite hard to track down so without any code to examine the job is made ever so slightly more difficult ;) Post up some of the code that you think could be associated to or causing your problems. Side note: Your punctuation and grammar is quite …

Member Avatar for nolife
0
1K
Member Avatar for praky

I'm not sure why you posted this 3 times, but it's really not an advisable habit to get in to... In ini_count(), you appear to read to the end of the file. Because of that, and since I don't see any sort of reset, I'm guessing your eofbit flag is …

Member Avatar for praky
0
90
Member Avatar for chinchan

I can think of a couple ways, but the best one depends on your answers to these questions: [list=1][*]Is there a particular reason it needs to be 1 and -1? [*]Can it be 1 and 0? [*]Is 0 considered "off" for the purposes of this exercise? [*]If 3 is yes, …

Member Avatar for Colezy
0
204
Member Avatar for gurram srinath
Member Avatar for frogboy77
-2
109
Member Avatar for Rikard

Q1: Hmmm.... Something like this has alot of overlapping constructors and function calls, it's an exercise in using resources efficiency. I'm actually working through a similar situation on a project I'm working on right now. This is how I'm approaching it: To prevent multiple re-allocations of the vector as it …

Member Avatar for Rikard
0
214
Member Avatar for rcplguy15

Your phrasing is a little awkward, so I might be missing something. But, if I'm understanding your question correctly, you should be able to simply break it into 2 input statements. [CODE]inFile >> face >> suit;[/CODE] Then, you can manipulate or store face and suit as you see fit.

Member Avatar for rcplguy15
0
331
Member Avatar for frogboy77

C++ automatically "promotes" values to the appropriate data types for certain operations. An int can be promoted to any of float, double, or long double. As a result, any of those versions of the function is an appropriate function call. To get around it, simply cast the first argument to …

Member Avatar for Fbody
0
142
Member Avatar for ASTA LAVISTA

[QUOTE=Akill10;1337799]Why do you want to return 0? What is it you are trying to make your program do?[/QUOTE] Returning an int from main() is what is required by the standard. The normal return from main() to indicate no errors occured is zero (0). Thus, the absolute minimum standards-compliant program is:[CODE]int …

Member Avatar for ASTA LAVISTA
0
412
Member Avatar for frogboy77

[QUOTE=frogboy77;1341888]been at this 2 months taking one step at a time using whats there first before thinking about importing more not avoiding it just learning thanks for the help i'll figure it out. remember when rebuking someone "one must learn to walk before one can run." if i was unwilling …

Member Avatar for frogboy77
0
90
Member Avatar for Bri426

Once you have entered "number", you should not change it again. You then need to use a different variable, usually called 'i' (but it can be called anything you like), to control your loop. [CODE]cout << "How many numbers: ": cin >> number; for (int i = 0; i < …

Member Avatar for frogboy77
0
234
Member Avatar for waphon
Member Avatar for chiwawa10
0
116
Member Avatar for dasari.prasad

Pointers and references are similar and are both used under similar circumstances. Really, a reference is just a pointer without all the extra syntax, but they are not freely interchangable. Which syntax you use for function calls depends on how the function being called is defined. Both are frequently used …

Member Avatar for ben1Greer
0
430
Member Avatar for Elven Princess

[QUOTE=Chris Bruner;1219162]I've got a library which you can obtain at [url]http://code.google.com/p/crylib/[/url] using subversion. It's basically my playground for learning and exploring some concepts. It was written using cbuilder, and gcc so it should be compatible with your system. The wiki gives a bit of an intro to some of the …

Member Avatar for Fbody
-1
96
Member Avatar for Ancient Dragon

I've noticed a similar behavior with the "Threads I've Posted in" button. It seems there is a lag in it. How long it takes to add threads seems fairly random, sometimes as much as an hour. Once added, the new posts behavior is fine. Perhaps it's some sort of cached …

Member Avatar for Fbody
0
122
Member Avatar for DemonGal711

You'll have to post your code that handles the output. I don't see any "missing" tags, but I do see some missing newlines.

Member Avatar for Fbody
0
112
Member Avatar for TinhornAdeniyi

How do you want it to look? If you only want "The CTEC students taking COSC 208 are: " to appear once, take it out of your loop. It's a pretty simple fix.

Member Avatar for mitrmkar
0
220
Member Avatar for cogitoergosum18

With a loop:[CODE] for (int i = 0; i < vector.size(); ++i) { /* add them up */ }[/CODE]

Member Avatar for mrnutty
0
204
Member Avatar for humantaco

[B]>>Can anyone post the code to these? [/B][URL="http://www.daniweb.com/forums/announcement8-2.html"]Nope.[/URL]

Member Avatar for Fbody
0
154
Member Avatar for humantaco

[URL="http://www.daniweb.com/forums/announcement8-2.html"]And what exactly have you done?[/URL]

Member Avatar for Fbody
0
162
Member Avatar for Kromletch

[URL="http://www.daniweb.com/forums/announcement8-3.html"][B][COLOR="red"][noparse]I'm sorry, I can't read your code very well.[/noparse][/COLOR][/B][/URL] Are they full state names or abbreviations? Either way, I doubt you need strings that are 50 chars long. Unless there is one I'm missing, you should only need about 20 chars.

Member Avatar for Fbody
0
271
Member Avatar for NathanMc

Boy, I would have done this with an enum, but it sounds like you can't. Can you use a switch? [CODE]switch (asciiGrade) { case 65: qpts = 4; break; case 66: qpts = 3; break; /* etc... */ }[/CODE] It works just like an if ... else, but it's not …

Member Avatar for NathanMc
0
318
Member Avatar for akmalhisyam

The extraction operator breaks the input when it detects a whitespace character. At the end of each input line there is a newline, which is a whitespace character. The newline character is not extracted and is left in the input stream as a "dangling" character. This occurs most often after …

Member Avatar for akmalhisyam
0
3K
Member Avatar for broli100

>>THAT ****ING CONST Is there to assure you that the file name will not be changed on you while it's creating the file and is entirely appropriate. You should not try to circumvent it. Please post the code of your "save as" function so we can see what you are …

Member Avatar for broli100
0
224
Member Avatar for neoraghav

You corrupted your input stream, you need to reset it and remove the offending char(s). You will need to use [URL="http://www.cplusplus.com/reference/iostream/ios/good/"]ios::good()[/URL] or [URL="http://www.cplusplus.com/reference/iostream/ios/fail/"]ios::fail()[/URL] to detect the stream corruption. You will then have to use [URL="http://www.cplusplus.com/reference/iostream/ios/clear/"]ios::clear()[/URL] to reset the stream. Then you will need to use [URL="http://www.cplusplus.com/reference/iostream/istream/ignore/"]istream::ignore()[/URL] to "throw away" the …

Member Avatar for neoraghav
0
153
Member Avatar for xsnake7

You'll have to store the return value. Right now, the return values are all being discarded. To store the return, declare a variable of the same type as the return, then use the assignment operator with a function call on the right of the assignment.[CODE] #include <iostream> using std::cout; using …

Member Avatar for xsnake7
0
247

The End.