2,827 Posted Topics

Member Avatar for jryans10

The first one uses the "new" operator and therefore uses dynamic memory on the "heap". This memory DOES NOT go out of scope when the line that created goes out of scope. You must free / deallocate that memory with the "delete" operator. This can be a good or bad …

Member Avatar for Narue
0
146
Member Avatar for Azmah

Giving the "hint" just made me assume it was one of those trick questions that it wasn't a math question at all but rather something where you sounded out the letters and it made some phrase or whatever. If it's a math problem with no tricks, just state the problem. …

Member Avatar for BDove
0
2K
Member Avatar for DarkPyros

Turning on some compile warnings will give you a clue! [quote] gcc dani.c -O -Wall -Wextra -pedantic -Wuninitialized dani.c:2: warning: return type defaults to `int' dani.c: In function `main': dani.c:3: warning: 'side3' might be used uninitialized in this function[/quote]

Member Avatar for WaltP
0
205
Member Avatar for naraayanan
Member Avatar for naraayanan
0
165
Member Avatar for stunnablaze

>>Who can calculate tax in C using Control Statement, Arrays, Functions and Pointers... I can! I can! >> if you are so good show me what you Got... OK, I can't resist a dare! I'll show you! Nice try. :icon_rolleyes:

Member Avatar for VernonDozier
-1
57
Member Avatar for PrimePackster

All your negative rep seems to come from WaltP and all for the same reason. Read his feedback and take it to heart. That said, everyone deserves a second chance, so you're now positive again.

Member Avatar for Narue
0
207
Member Avatar for cool_zephyr

Forget about the programming part for a second. How do you propose to create something curved(sphere) with something that only has straight edges(triangle)? It seems geometrically impossible. Perhaps you are trying to create something "close to" a sphere? >> all of them only describe creating a sphere using some library …

Member Avatar for cool_zephyr
0
1K
Member Avatar for coxxie

You have way too much code involving user input in the same functions as the file reads and writes. If you are advanced enough to use read, write, sizeof, and other fairly low-level function calls, you're advanced enough to partition the program into different segments. This isn't just being nit-picky. …

Member Avatar for VernonDozier
0
2K
Member Avatar for triumphost

How could decrypting fsdh9hsdg to SetMousePos(X, Y) at runtime help? You don't do anything with the C++ code at runtime. It's too late by then. fsdh9hsdg obviously isn't going to compile. I could see having hard-coded encrypted values in variable assignment code which were decrypted at runtime. I can definitely …

Member Avatar for VernonDozier
0
170
Member Avatar for krehman143

I assume it will surprise no one that this is a cross post. [url]http://www.cplusplus.com/forum/general/58817/[/url]

Member Avatar for PrimePackster
-2
161
Member Avatar for hamby

It's a scoping issue. See those brackets where you declare c inside of them? You can only use c within those brackets. That's the error. You need to declare c on line 2, not lines 13 and 16. [EDIT] You don't need to declare it on line 2. Declare it …

Member Avatar for hamby
0
191
Member Avatar for KingAudio

[QUOTE=KingAudio;1730862]I am in an 11th grade computer science class learning C++ and I feel that the class is going to end before I learn how to apply C++. What I want to know is what do I need to learn to start applying C++ into tasks like software development, game …

Member Avatar for VernonDozier
0
440
Member Avatar for kikic

If you have it working for a 3 x 3, post the code for that and perhaps people can offer advice for how to generalize to M x N.

Member Avatar for zeroliken
0
313
Member Avatar for johnnydarten

>> The following program builds and compiles just fine I'm a little surprised at that. You have array sizes that appear to be based on variables(i.e. unknown at compile time). I haven't worked my way through the program to see if these sizes will always be the same when they …

Member Avatar for johnnydarten
0
1K
Member Avatar for namelyia
Re: help

[url]http://www.learncpp.com/cpp-tutorial/810-const-class-objects-and-member-functions/[/url] You have a function called print() which promises to not change an object due to its "const" qualifier. Within that function, it calls a function called getName() which DOES NOT make that promise. So can print() truly make good on its promise to not change anything? No. Think of …

Member Avatar for VernonDozier
0
97
Member Avatar for floatingDivs

[code] #define NULL 0 int main() { int i = 5; int* p = NULL; int* q = NULL; p = &i; //No error as p is assigned the address of i p = *&i; //Error as p is assigned the contents at the address of i p = &*i; …

Member Avatar for floatingDivs
0
718
Member Avatar for mattitude

I'll resist the urge to post STFW or post a Let Me Google That For You link. More details are needed, not least of which is what operating system you plan on using and what your knowledge level and skill base is.

Member Avatar for VernonDozier
0
205
Member Avatar for MooGeek

If you want a DEGREE in Computer Science, it'll require passing quite a few math classes in order to get it. That's if you want the degree. A lot of people seem to do just fine without the degree.

Member Avatar for vegaseat
0
162
Member Avatar for devindamenuka

It's a bit vague, but this is one of the most common assignments given by C++ professors. They must all get together and decide to give an airline reservation assignment. A search for "airline reservation" will surely get tons of hits. No one uses a database. It adds an unnecessary …

Member Avatar for VernonDozier
0
159
Member Avatar for terence193

The question is impossible to answer without more info from you. We don't know what variables might be needed, we don't know which of them might be global, we don't know if there are any structures set up, we don't know precisely what you need to save in the file …

Member Avatar for Trentacle
0
117
Member Avatar for roona

This thread, or actually the other one, gave me a chuckle. It doesn't set the new record for chutzpah, but it ranks up there. Apparently it's not just a cross-post, it's a quadruple post (here, cprogramming, Stack Overflow, bytes.com). I almost want to up-vote it for the brazenness. Nah, down-vote …

Member Avatar for VernonDozier
0
242
Member Avatar for mrnutty

>> May he rest in peace in heaven. I'd love to see the look on his face if he woke up and found out he was in heaven.

Member Avatar for mrnutty
0
113
Member Avatar for adohertyd

Depending on how much memory you have, you may or may not have enough memory to store all the strings in the dictionary in RAM. If you can end up with an alphabetically sorted array of type char* in RAM, that's ideal, at which point you can do quick binary …

Member Avatar for VernonDozier
0
212
Member Avatar for placebo1

Lines 17 to 21... [code] fscanf(p, "%s %lu", a, &parameters[0]); // line 17 parameters[0]=pt1[0]; // line 19 fscanf(p, "%s %lu", a, &parameters[1]); // line 20 parameters[1]=pt1[1]; // line 21 [/code] Seems like whatever values are read from the file on 17 and 20 are immediately overwritten on lines 19 and …

Member Avatar for placebo1
0
185
Member Avatar for misalazeem

What about the following scenario? 1) Your king is not in check. 2) It's your move and any move you make places your king into check. Is that checkmate?

Member Avatar for arkoenig
0
2K
Member Avatar for Vasthor

[code] #include <iostream> int main() { //{ int i = 0; while(i < 10) ++i; //} std::cout << i << std::endl; return 0; } [/code] Lines 6 and 10. Brackets commented out = compiles. Brackets uncommented = will not compile. Therefore the issue is the scope of the variable i, …

Member Avatar for Vasthor
0
247
Member Avatar for king03

[code] void main() { ifstream inFile; inFile.open("Input.txt"); cout<<"opened"<<endl; system("pause"); } [/code] This is fine. The rest of the code you posted is irrelevant. No function is ever called. How do you know it doesn't open? There is no attempt to read from it and there is no check to see …

Member Avatar for VernonDozier
0
208
Member Avatar for th_3

Read the question again. The word "weight" appears nowhere. The is a math problem and requires you to understand that arrays are contiguous and also how a 2-D array uses the [x][y] pair, starting address, and array size too convert it to an address. presumably there's a formula in your …

Member Avatar for th_3
0
454
Member Avatar for VernonDozier

I've made a small program that draws black rectangles on a JPanel at random places. I would like to give the user the option to save this JPanel as a .gif file, but I'm not sure where to start. The function I need to write is SaveJPanelAsGIF below on line …

Member Avatar for ferwerda
0
420
Member Avatar for Kuroshi
Member Avatar for Panathinaikos22

Forget about whether it's strong encryption or not. I don't see how it can work at all due to two factors... 1) rollover. 2) integer division. 2) Non-prime numbers 1 and 1 are trivial, so these won't come up, but what about a character like '@', which is 64 in …

Member Avatar for VernonDozier
0
389
Member Avatar for demroth

[QUOTE=demroth;562109]I am trying to test the code snippet Lerner created but when I compile I get the following error.... [Linker error] undefined reference to `gToken(std::basic_ifstream<char, std::char_traits<char> >&, std::string*)' ld returned 1 exit status C:\c-- lexical analyzer\Makefile.win [Build Error] ["c--] Error 1 Can anyone tell me just what this error means …

Member Avatar for demroth
0
3K
Member Avatar for iGuardian

>> My question is regarding if i should have the user input a file name they wish to output the information to within main or in another void function Either will work. My general preference in these things is to use a function. It really doesn't matter. I don't see …

Member Avatar for iGuardian
0
1K
Member Avatar for mftbob

Code tags and formatting. Your post is impossible to read without them. [noparse] [code] // code here [/code] [/noparse] [ICODE]srand(time(0))[/ICODE] should be called only once at the very top of main. It should not be inside of a loop. Get the [ICODE]system("cls")[/ICODE] calls out of there. It's impossible to debug …

Member Avatar for Schol-R-LEA
0
4K
Member Avatar for BenjaminH

Lines 36, 37 and 44 and 45 -- I'm surprised this compiles. You're declaring an array of a variable size, but you are not using the "new" operator. Line 61 -- where did the number 25 come from? Line 63 -- You're assigning a character to equal a string? I'm …

Member Avatar for Lerner
0
148
Member Avatar for coroshea

Line 31 -- I fail to see the point of calling this function with a negative size value. It does absolutely nothing. Line 41 -- Create a new pizza with uninitialized memory. Lines 42 and 43 -- Display the uninitialized memory. Lord knows what you'll get. I think a string …

Member Avatar for Schol-R-LEA
0
171
Member Avatar for neveragn

Line 21 overrides any effect line 17 has. Line 24 and 25 don't make sense. [code] for(j<=100;i>j;++i){ printf("%d", array[n]); }[/code] The loop counter is i, but you are displaying the index n, isn't in the loop and doesn't vary. The initial part of the loop is "j <= 100". I'm …

Member Avatar for neveragn
0
287
Member Avatar for coolbeanbob

I take it that line 40 executes properly, but line 42 does not? Right off the bat, I see a problem in line 69. size appears to be 100,000, count is assigned to equal size, and first_unsorted can equal anywhere up to 99,999, and that's used in line 69 as …

Member Avatar for coolbeanbob
0
121
Member Avatar for Vasthor

Line 40... [code] for (num_ele current_index = [COLOR="Red"]1[/COLOR]; current_index [COLOR="Red"]<=[/COLOR] input_size; ++current_index) [/code] Indexes start at 0, not 1, and they must be LESS THAN the array / vector size. You simply got lucky when it didn't crash when you entered one string. It could have. You got garbage because …

Member Avatar for Vasthor
0
156
Member Avatar for coolbeanbob

Seems like you should remove the i, not the t. For a 2-D array, I assume you are doing this... [code] matrix[t][i] = temp;[/code] and you want to convert that code. You can either add an element to a vector or change an element that you already have. In your …

Member Avatar for VernonDozier
0
176
Member Avatar for JayBaron

Copy line 82 into line 13. They need to match and line 13 is wrong. It needs to be "int&", not "&int". The call on line 71 is incorrect. You are passing by reference, which is similar to passing the address behind the scenes, but not the same. You need …

Member Avatar for WaltP
0
656
Member Avatar for PrimePackster

>> But with the nested if in place the "code have no effect error" occur. First, I imagine it's a warning, not an error. Depending on compiler flags, warnings may be turned into errors. Second, what line number and what's the exact error message?

Member Avatar for Fbody
0
357
Member Avatar for A&M_guy

The sort looks OK to me. What's wrong with the output? And have you verified that everything reads into the structures properly from the file? Note : I assume you have precisely 30 elements? If not, all bets are off because your sort code assumes that. I notice a "peek" …

Member Avatar for A&M_guy
0
268
Member Avatar for Eldyvoon

>> use seek? Sure, why not? Seriously, if you want a more useful answer, you'll need to post a much more descriptive question. Your question is unanswerable as written. [EDIT] Perhaps not. Moschops apparently understands what you are asking.. [/EDIT]

Member Avatar for Eldyvoon
0
270
Member Avatar for alexander1s

This actually compiles? [code] [COLOR="Red"]int[/COLOR] months[MONTHS]= {[COLOR="Red"]"01"[/COLOR], "02", "03", "04", "05", "06", "07", "08", "09", "10", "12"};[/code] "01" isn't an integer.

Member Avatar for VernonDozier
0
140
Member Avatar for bmanzana

[url]http://www.cplusplus.com/reference/string/string/erase/[/url] [quote] pos Position within the string of the first character to be erased. [COLOR="Red"]If the position passed is past the end of the string[/COLOR], an out_of_range exception is thrown. [/quote] I see no checking for this condition and I see no catching of any exceptions, so if this is …

Member Avatar for bmanzana
0
109
Member Avatar for skylinedrifter

Seems fairly straightforward. Don't bother with numbers 2 or 3 till you understand number 1, which you apparently don't, so you need to take a basic tutorial on enumerated types. It's just this. [code] enum Planet {MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO}; [/code]

Member Avatar for thines01
0
146
Member Avatar for becraxie

The error lines don't match up with the code lines you posted. Lines 115 to 130 -- This is code in the middle of nowhere. Is this supposed to be a function? Ditto lines 132 to 147. Perhaps there are some bracket mismatches?

Member Avatar for mathijs
0
535
Member Avatar for toneranger

[quote] I now need to be able to compare data using the date [COLOR="Red"](string)[/COLOR] and time (unsigned int) as 'sort by' fields. Essentially, I'd like to be able to do something like: [/quote] I'd say that's your problem right there. If you are storing the date as a string and …

Member Avatar for WaltP
0
2K
Member Avatar for smmcfarl

You posted what the output SHOULD be. What is it actually (I assume it's garbage of some sort, but what kind of garbage?)

Member Avatar for smmcfarl
0
149

The End.