6,741 Posted Topics

Member Avatar for lochnessmonster

[QUOTE]wchar_t is a macro windows uses to replace it with either "CHAR" or "WCHAR" when UNICODE is defined.[/QUOTE] I believe you mean TCHAR. wchar_t is a keyword in C++. [QUOTE]MSDN says that UNICODE is defined by default.[/QUOTE] When you create a new project from a template in Visual Studio. This …

Member Avatar for Narue
0
110
Member Avatar for SourabhT
Member Avatar for Agni
0
142
Member Avatar for sdr001

[QUOTE]If the file is there, the new elements need to override everything in the file, pretty much clear it out and write to the file. If the file is not there, it just writes the elements to the file.[/QUOTE] The default behavior when opening for writing is to truncate the …

Member Avatar for sdr001
0
219
Member Avatar for spoonlicker

[QUOTE]Because I honestly feel like I'll never understand them(it's been years by the way).[/QUOTE] If you want to feel like you understand things, quit programming immediately. I like to say that any decent programmer will be in a constant state of confusion. [QUOTE]my EXACT question is can it be done?[/QUOTE] …

Member Avatar for katokato
-1
695
Member Avatar for super-duper

[iCODE]delete ptr[/iCODE] doesn't remove the node from the list, it simply releases the memory. The list still refers to a dangling pointer. deleteNode is also rather inefficient because it traverses the list twice: first to find a match and again to do the deletion. You can roll these together: [code] …

Member Avatar for Narue
0
92
Member Avatar for ontherocks

[QUOTE]If there are a bunch of unique items, which one (vector or set) wold be more efficient to search for a particular item by value and why?[/QUOTE] The performance characteristics of the set class imply a balanced binary search tree (or similar) structure. vector is essentially a dynamic array. You'd …

Member Avatar for Narue
0
172
Member Avatar for spoonlicker

[QUOTE]I tried to include both headers, did both required tasks but only one of the windows opens.[/QUOTE] There can only be one entry point into the program. For a console project that entry point is the traditional main(). For a Windows project, the entry point is WinMain. If you want …

Member Avatar for peter_budo
0
2K
Member Avatar for lochnessmonster

No, it's not bad. Only C++ purists will rag on you about it, but they're in a world of their own anyway.

Member Avatar for pritpal.singh88
0
233
Member Avatar for lexusdominus

In other words, you're completely incompetent. Massive ideas but an inability to follow through with them makes you utterly valueless. Then again, you're very obviously a troll who has no interest in following through with massive ideas. Rather, you're simply trying to get jollies out of wasting people's time.

Member Avatar for mike_2000_17
0
140
Member Avatar for spoonlicker

[QUOTE=spoonlicker;1477807]No, I mean machine language and not Assembly programming.[/QUOTE] Totally saw that one coming. :icon_rolleyes: If you want to work directly with machine language, get a hex editor. The only way to work with machine language is to directly modify the bytes of a file much the same way an …

Member Avatar for spoonlicker
0
3K
Member Avatar for caut_baia

No, std::vector does not perform a deep copy of pointer items. You must do it manually or use a smart pointer.

Member Avatar for caut_baia
0
3K
Member Avatar for spoonlicker

[QUOTE]it still doesn't help me with my program in OpenGL.[/QUOTE] That's because [i]if[/i] you truly don't understand as you say, you have no business delving into Win32 and OpenGL before properly learning the basics of C or C++. [QUOTE]Handles like Windows HWND? I know how to use those pretty fairly, …

Member Avatar for papanyquiL
-5
233
Member Avatar for Sahilroy

Sorry dude, we're not going to do your homework. I hope you don't think we're dumb enough to fall for the "this is a challenge for everyone!" trick.

Member Avatar for Narue
0
110
Member Avatar for poloblue
Member Avatar for Narue
0
311
Member Avatar for manongjulius

[B]>int array[size];[/B] This won't work in standard C++. Array sizes must be compile time constants, and your size variable is not. If it compiles, you're relying on a compiler extension which isn't good when learning the language. [B]>bubblesort(array[],size);[/B] The brackets aren't necessary when referring to the array object itself: [code] …

Member Avatar for manongjulius
0
288
Member Avatar for spoonlicker

[QUOTE]Honestly, can it all be done with machine language and native graphics card and sound card instructions and nothing more?[/QUOTE] Yes. But writing machine code directly and interfacing directly with hardware is both difficult and tedious. I assume since you're excessively insane about not using the efforts of others that …

Member Avatar for spoonlicker
-3
110
Member Avatar for pkfx

[QUOTE=user422;1477367]Here's an example based on your request: [CODE]#include <iostream> int main(){ double numInput; while(true){ std::cout << "Enter a Number (Max 10 digits)(99 to Exit): "; std::cin >> numInput; if( numInput - static_cast<int>(numInput) != 0.0 ) std::cout << "Invalid Try Again" << std::endl; else break; } if( numInput == 99.0 ) …

Member Avatar for Narue
0
116
Member Avatar for muthuivs

>could you elaborate I'd be happy to elaborate. jwenting was saying to RTFM. If that doesn't work, tell us what compiler you're using and we'll tell you how to get an executable file out of it.

Member Avatar for raj.patel301
0
572
Member Avatar for Sundayy

[QUOTE]I automatically know what it'll do because "I" came up with it.[/QUOTE] Until you leave the code and come back in a year and it looks like it was written by someone else. Then you're SOL.

Member Avatar for peter_budo
0
446
Member Avatar for Juan-Ellyn
Member Avatar for Swiftle

You can implement operator== for your class, or alternatively use find_if, which takes a predicate: [code] #include <algorithm> #include <functional> struct id_match: public binary_function<A, int, bool> { bool operator()(const A& obj, int id) const { return obj.ID == id; } }; //... match = find_if(l.begin(), l.end(), bind2nd(id_match(), 999)); [/code] A …

Member Avatar for Swiftle
0
148
Member Avatar for imobby
Member Avatar for imobby
0
164
Member Avatar for jimJohnson

[QUOTE]2) Learn how to indent C++ code.[/QUOTE] The code is indented properly. Perhaps you could get to the root of the problem instead and mention that mixing tabs and spaces can affect indentation when pasted outside of an IDE.

Member Avatar for jimJohnson
0
224
Member Avatar for sdr001
Member Avatar for Transcendent

[QUOTE=spoonlicker;1475292]I know this is off-topic, but why did you assume I was male?[/QUOTE] Unless you're talking about the snipped profanity, I don't see any such assumption in this thread. But it's generally a good assumption on this kind of forum. It's also easier to make an assumption and go with …

Member Avatar for mike_2000_17
0
458
Member Avatar for Rapidee

How to search the forum before asking a question that's been answered countless times before?

Member Avatar for Narue
-2
23
Member Avatar for skinwah

There's no need to copy members individually. You can simply copy the structure objects: [code] timesheet[j] = timesheet[j + 1]; [/code]

Member Avatar for skinwah
0
141
Member Avatar for Zvjezdan23

How do you attach a pointer to an int? [code] int i; int *p = &i; [/code] Right? Well, pointers are very regular, and you'll find that the same syntax works almost across the board: [code] vector<int> v; vector<int> *p = &v; [/code]

Member Avatar for Narue
0
63
Member Avatar for spoonlicker

struct and class are essentially the same thing, just with different default access. structs are public by default and classes are private. typedef is a completely different beast, and I'm curious what kind of misunderstanding prompted you to lump them together. Perhaps this little trick from C to avoid typing …

Member Avatar for Narue
0
1K
Member Avatar for fish234

Since you didn't mention what compiler or OS you're using, the only suggestion I can make is the std::system function from <cstdlib>. Look that up in your standard library reference.

Member Avatar for Narue
0
305
Member Avatar for JaviP
Member Avatar for daniel1977

[QUOTE]I understand the validation would be a display of the entered date so the user can verify it is correct.[/QUOTE] That's probably not a good assumption. More likely is that you're required to programmatically evaluate the date and determine if it's valid. [QUOTE]1. Does this declare a data type or …

Member Avatar for Narue
0
362
Member Avatar for ComicStix

[QUOTE]My computer science teacher stinks.[/QUOTE] [QUOTE]the book sucks and doesn't explain anything[/QUOTE] [QUOTE][...] even though this class stinks?[/QUOTE] Did you consider that the problem might be on your end? Far be it from me to suggest that all teachers are great and it's the students who fail at learning, but …

Member Avatar for rscubelek
0
229
Member Avatar for lochnessmonster

[code] #include <iostream> template <typename T> void display(T value) { std::cout<< value <<'\n'; } int main() { int a = 123; double b = 123.456; display(a); display(b); } [/code] This causes the template to be instantiated twice, once with each unique signature: [code] #include <iostream> void display(int value) { std::cout<< …

Member Avatar for L7Sqr
0
995
Member Avatar for lovely girl

[QUOTE]what is complexity in c++[/QUOTE] Time complexity of an algorithm is how long it takes the algorithm to complete, relative to the size of its input. If you have a question that relates to C++ (since time complexity is pervasive across the whole of computer science), be more specific.

Member Avatar for mrnutty
-3
105
Member Avatar for MuaazKhalid

[QUOTE]I don't know where it from getting arguments.[/QUOTE] The C++ runtime environment, along with doing things like opening standard streams and such, will prepare command line arguments and call main.

Member Avatar for Narue
-1
129
Member Avatar for mitrious

[QUOTE]Can anyone help me think of a better solution?[/QUOTE] You can follow a similar train of thought as nrand. Calculate the number of RAND_MAX sized buckets in your extended range, then for a randomly selected number of those buckets, add RAND_MAX to r.

Member Avatar for pseudorandom21
0
1K
Member Avatar for prvnkmr194

You want a random shuffle. Simply filling the array with random values will very likely produce duplicates. Shuffling multi-dimensional arrays is harder, so the usual advice is to shuffle a one-dimensional array and then copy the results into your final two-dimensional array: [code] #include <stdio.h> #include <stdlib.h> void swap(int *a, …

Member Avatar for prvnkmr194
0
438
Member Avatar for Behi Jon

[QUOTE]Why I get access violation in this code ?[/QUOTE] Because pointers are not magic. When you declare a pointer, it doesn't automatically point to an infinite amount of memory. In fact, it doesn't point to usable memory at all. You have to explicitly point it to memory that you own, …

Member Avatar for Narue
0
100
Member Avatar for elsiekins

[QUOTE=elsiekins;1470225]Hello Using : [CODE] cout << "enter 5 letter"; getline(cin, letter); [/CODE] executes fine but when running PC- Lint: getline(cin, expectedLabel): error 534: (Warning -- Ignoring return value of function 'std::getline(std::basic_istream<char,std::char_traits<char>> &, std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)' error 830: (Info -- Location cited in prior message) I was wondering if anyone could tell …

Member Avatar for Narue
0
259
Member Avatar for AnGeL_69

No, we don't do homework. But if you do the work yourself, we'll be happy to help you along.

Member Avatar for khanmj89
0
250
Member Avatar for JordanHam

You really have no choice but to shift elements and overwrite the elements to be deleted: Original: {[COLOR="Green"]1,2,3,4,5,6,7[/COLOR]} Delete 4: {[COLOR="green"]1,2,3,[/COLOR][COLOR="Red"]5,6,7[/COLOR],7} Delete 5: {[COLOR="Green"]1,2,3,[/COLOR][COLOR="Red"]6,7[/COLOR],7,7} The size of the array won't change though (I gave an example of how that might look with the black elements), so you need to maintain …

Member Avatar for Fbody
0
159
Member Avatar for realproskater

Backslash in a string literal begins an escape character. If you want a literal backslash, double them up: [code] infile.open("C:\\201\\PigLatin.txt"); [/code] Alternatively, you can use forward slashes. That works too: [code] infile.open("C:/201/PigLatin.txt"); [/code] [QUOTE]missing function header (old-style formal list?)[/QUOTE] This means the compiler thinks you're starting a function body. Usually …

Member Avatar for realproskater
0
1K
Member Avatar for tomtetlaw

[QUOTE]Why does fopen_s have the paramater FILE **_File rather then the FILE *_File that fopen has?[/QUOTE] Standard fopen returns the FILE pointer, but fopen_s instead returns an error code. Thus, an output parameter in the form of a pointer to a pointer to FILE is used to "return" a handle …

Member Avatar for tomtetlaw
0
246
Member Avatar for Eagle4Ever

What kind of hacker? You have the traditional hackers who treat learning new things almost as a religion, and the more recent hackers who break into and defend systems. Are you talking about the subculture as a whole, or do you want individual anecdotes? I can personally vouch that there's …

Member Avatar for WaltP
0
221
Member Avatar for knight92

[QUOTE]My question is that everyone says C/C++ is more powerful than many other languges e.g Visual basic but why is it more powerful.[/QUOTE] Not everyone. Making such a claim is misleading because the definition of "powerful" hasn't been nailed down. Yes, C and C++ are both powerful languages, but other …

Member Avatar for Adak
0
364
Member Avatar for ajst

I don't really see how this would help. Either you know the material or you don't. A thread of interview questions won't change that. You might get lucky and be asked a question that shows up in this thread, but that's kind of like sleeping with the textbook under your …

Member Avatar for Moschops
0
92
Member Avatar for ravenous

[QUOTE]However, const_reference at() const never gets called. Can anyone see why this is?[/QUOTE] None of your objects are const. The compiler isn't exactly going to say "oh, that call is on the right hand side of an assignment, the programmer must want me to use the const version of this …

Member Avatar for ravenous
0
255
Member Avatar for ahtaniv

[QUOTE]1. Do we have static classes in C++?[/QUOTE] Since this question was given to you by a Java programmer, you have to consider what a static class is in Java and then see if C++ supports the same behavior. In Java, a static modifier is only allowed on nested classes, …

Member Avatar for Narue
0
188
Member Avatar for aguilaron
Member Avatar for Narue
0
1K

The End.