6,741 Posted Topics

Member Avatar for daviddoria

>but for simple cases (just like this one, where all it is doing is >storing a number), it's not bad practice to just make it public? It depends on whom you ask this question. Some people will tell you that public data is absolutely evil. Others will tell you that …

Member Avatar for daviddoria
0
214
Member Avatar for meabed

>I don't recommend this method because it only works with summable values. Not to mention that you also risk integer overflow and undefined behavior.

Member Avatar for Lisa1110
3
1K
Member Avatar for tarekkkkk

i r nt knowing wut t3h hell ur talkng abt lol rofl jejeje!!!!!111 So far you've committed every noob sin in the book. How about trying to ask an actual question, asking it in the form of a complete thought, and not using lame abbreviations and chat speak. This forum …

Member Avatar for jbennet
0
806
Member Avatar for nishidh

You're going to have to ask a real question, and telling us how you've attempted to answer the question (before running to us) would help greatly.

Member Avatar for Salem
0
109
Member Avatar for anu123d

strcmp and friends already do a case sensitive comparison. It's easy to write a function that does a case insensitive comparison; it's just the same algorithm but with tolower or toupper matching the case: [code=c] int nocase_strcmp ( const char *a, const char *b ) { while ( tolower ( …

Member Avatar for anu123d
0
11K
Member Avatar for raghavendra83
Member Avatar for daviddoria

A stringstream is still a stream. When you read to end-of-file, you need to clear the state before you can do anything substantial with the stream again: [code=cplusplus] linestream.clear(); linestream << line; ... [/code]

Member Avatar for Freaky_Chris
0
780
Member Avatar for s-a-n-d-e

In general you need to write your own input mechanism that reads a character without echoing and prints a suitable mask character as a manual echo. C++ doesn't support raw input like that, so you'll have to drop to a non-portable solution such as getch: [code=cplusplus] #include <iostream> #include <string> …

Member Avatar for Narue
0
83
Member Avatar for slimjimmer

[code=c] #include <stdio.h> #include <stdlib.h> #include <time.h> int main ( void ) { int r; srand ( (unsigned)time ( NULL ) ); r = rand(); printf ( "random number = %d\n", r ); return 0; } [/code]

Member Avatar for slimjimmer
0
179
Member Avatar for serkan sendur

You only need to explicitly free resources that you explicitly ask for. For example, a FILE* given to you by fopen needs to be closed, and a pointer given to you by malloc needs to be freed.

Member Avatar for Narue
0
104
Member Avatar for kenji

I'd say append the delimiter onto cust if fscanf succeeds. You say this "didn't work", but that's a useless statement without a full description of what it does, what you expected it to do, and the actual code so we can verify that you did it correctly.

Member Avatar for death_oclock
0
77
Member Avatar for cppnewb

There are two forms of getline that concern you in this case. The first is a member function of cin: [code=cplusplus] char buffer[BUFSIZE]; cin.getline ( buffer, sizeof buffer ); [/code] Note that the argument is an array of char, and the maximum number of characters you want to fill it …

Member Avatar for cppnewb
0
414
Member Avatar for wyerleader

>Is there any options in control panel to delete a unwanted thread? No, can you imagine the havoc that would cause? If you want a thread deleted, contact a suitable moderator. We'll review your case and decide whether or not to honor the request.

Member Avatar for KeithBolt
0
121
Member Avatar for Leopold

I assume you're using [ICODE]system ( "PAUSE" )[/ICODE]. My first inclination is to say that this solution is a bad idea anyway, and if it doesn't do exactly what you want, that's all the better for convincing you not to use it. :D The usual recommendation for pausing a program …

Member Avatar for William Hemsworth
0
10K
Member Avatar for Somali Rathore

>How can I exchange 2 variables values without using any 3rd temporary variable. Most likely your teacher is expecting this: [code=c] a ^= b; b ^= a; a ^= b; [/code] But I'd recommend you find a new teacher because your current one is likely too focused on archaic trivialities …

Member Avatar for Narue
-2
203
Member Avatar for integer*09

When you find yourself using names like xxx0, xxx1, xxx0_1, xxx2_1, etc..., you should probably be using an array instead.

Member Avatar for integer*09
0
89
Member Avatar for tomtetlaw

Any decent compiler will allow you to define macros from the command line, so you can define your WINDOWS macro when compiling: [code] myawesomecompiler -DWINDOWS 1 mycode.cpp [/code]

Member Avatar for Narue
0
47
Member Avatar for Clockowl

I'm curious why you expected a pointer to const char to be successfully converted to a pointer to std::string. The two are not compatible pointer types. The second example works because the string literal is used as a constructor argument in generating a temporary std::string object.

Member Avatar for Narue
0
310
Member Avatar for Dannyo329

>Cos' when I search on google and I when thought I had >found a great site, its actually for C programmers. The usage of the header is virtually identical between C and C++. The only difference is that if you use <ctime>, you need to remember that all of the …

Member Avatar for Narue
0
125
Member Avatar for egolovin
Member Avatar for Comatose
0
135
Member Avatar for LucyB

What you asked for, by my reading, is an array that grows automatically to fit whatever index you provide. So if you say int array[], then try to index array[100], the array will resize itself to have 101 elements. You [b]can[/b] do this with dynamic arrays and such things as …

Member Avatar for Narue
0
68
Member Avatar for moaath

>for example what kind of function you recommend me to >use and what kind of loops you recommend me to use also Well, I'd recommend what the requirements say, since they're very specific about what functions and loops you should use. :icon_rolleyes:

Member Avatar for MosaicFuneral
0
218
Member Avatar for TheEnd2020

It's Friday, you have plenty of time to ask us a specific question and get a specific answer.

Member Avatar for Narue
0
33
Member Avatar for dm215

>This is wrong, isn't it? If the value of argc really is changing (sometimes debuggers can be misleading) then looking for overflow would be my first task. It's entirely possible for memory overflow to spill into other variables and corrupt your data.

Member Avatar for dm215
0
99
Member Avatar for 3pid

Choose the one you like the most. :icon_rolleyes: By the way, if you want to learn a language "completely" you'll likely end up learning nothing else. For example, there's probably not a human on this planet who can claim complete knowledge of C++.

Member Avatar for Ramy Mahrous
0
128
Member Avatar for winrawr

Do a google search for linked data structures (ie. linked lists, binary trees) and you'll discover a good use for pointers.

Member Avatar for winrawr
0
108
Member Avatar for ahspats

Most of the functions in the stdio library will take a pointer to FILE. scanf and printf assume stdin and stdout, respectively, so you might not have had cause to jump to something like fscanf and fprintf. The idea is to open the file and close the file, but in …

Member Avatar for ahspats
0
98
Member Avatar for noodlecode

>is it correct to say that to take advantage of polymorphism at >runtime, all of the base class functions that will be overriden must be virtual. Virtual member functions are how C++ supports run-time polymorphism, so it is correct to say that to take advantage of run-time polymorphism, you need …

Member Avatar for Narue
0
94
Member Avatar for Clockowl
Member Avatar for Clockowl
0
87
Member Avatar for TasostGreat

>My answer which is the fastest way to achieve this on Linux compiled with gcc I'd say skip the standard stuff and drop down to the write function as a start. This removes a potential level of abstraction, but of course you should be profiling all of these options to …

Member Avatar for TasostGreat
0
1K
Member Avatar for tibrah001

>But i have no idea on what kinda system to develop. I swear, I completely fail to understand how you can get passing grades through four years of classes and remain totally clueless. Are you seriously suggesting that you sat through lecture after lecture and [B][I][U]nothing[/U][/I][/B] peaked your interest? Or …

Member Avatar for Ezzaral
0
91
Member Avatar for arazum

It doesn't matter how the size is defined, you can't initialize an array member arbitrarily like you can with local arrays. You can default initialize it, but that's about as good as it gets, and with a const array, it's not terribly useful: [code=cplusplus] template<int s> class something { const …

Member Avatar for arazum
0
175
Member Avatar for cozzoli

>Is the latest operating system critical for C++ developers in making a job change decision? The target system is a critical piece of information, if that's what you're asking. It doesn't have to be bleeding edge (C++ is older than any hardware and OS a game would reasonably target these …

Member Avatar for Narue
0
83
Member Avatar for kanaku

Clearly the same message is used for both good and bad rep, which means somebody didn't think very hard about the implications before trying to be all warm and fuzzy to users. ;)

Member Avatar for jbennet
0
104
Member Avatar for ~s.o.s~

>Akikan [since I am a harem/romance lover at heart] It's hard to come up with a good harem series. I'll probably watch it anyway because Megumi Toyoguchi is one of the seiyuu. >Asu no Yoichi! Ugh. I've got horrible visions of yet another attempt a this cliché. I'll give it …

Member Avatar for ~s.o.s~
1
172
Member Avatar for uxp

>Both will fulfill your need. Though all things being equal, the first is arguably easier to prove correct without giving it much thought beyond knowing your "one past the end" value.

Member Avatar for uxp
0
141
Member Avatar for tomsta

>My theory is that if you program in a certain language it >affects the way that you are talking/writing/thinking. That's a good theory. I try to use the full breadth of my experience regardless of the language (ie. mixing useful concepts from different paradigms), but that's definitely a conscious thing. …

Member Avatar for jbennet
0
204
Member Avatar for gproggramer175

>i want to program a videogame. I'd estimate that 99% of beginners start programming because they want to make games. >I bought c++ for dummies Hmm, I'm generally hostile toward "for Dummies" books because they're more often than not "by Dummies" as well. The quality of these books hasn't impressed …

Member Avatar for MattEvans
0
94
Member Avatar for serkan sendur

I can't decide if this is a joke or not. Anyway, the easiest way to look at the machine code (what people typically mean when they talk about "ones and zeros") is with a hex editor. Some hex editors even give you a binary view.

Member Avatar for serkan sendur
0
213
Member Avatar for BevoX

Initialized the pointer to 0 if you aren't allocating memory. You can safely delete a null pointer and it will effectively be a no-op.

Member Avatar for BevoX
0
122
Member Avatar for Q8iEnG

I think you have your terminology mixed up. Can you give an example of one or two "exception handlers" that you're familiar with so we know what the hell you're talking about?

Member Avatar for Q8iEnG
0
96
Member Avatar for cppnewb

>On the other hand a simple addition to tm_mday may produce >wrong dates and the real implementation (VC++ 2008) returns a >very strange results after mktime of that "new date". Granted I don't do a lot of date/time work, but I have yet to see what you've described as a …

Member Avatar for cppnewb
0
9K
Member Avatar for AKJo

>I have specilized in Delphi [probably] since you were still wearing >short dresses; since Delphi was released by Borland in 1990. 1) How long you've been working with a language has no bearing on following Daniweb's rules. Since you're (so you claim) not a child, we expect you to be …

Member Avatar for Narue
0
149
Member Avatar for nikileshsa

Wow, grumpier. That was total BS. :icon_rolleyes: >The first line puts a space into the first char of a, and a zero into >the second char. All other elements of a are uninitialised. String literal initialization is equivalent to a brace enclosed initialization list. [ICODE]char a[LINE_SIZE + 1] = " …

Member Avatar for grumpier
0
187
Member Avatar for Ronen444

You probably forgot to terminate the last class defined in InputHandler.h with a semicolon.

Member Avatar for Narue
0
277
Member Avatar for karang

>Am I missing something. Yes. iDeveloper gave you the fix, but the reason for it is that you're initializing pointers to string literals. The problem isn't the pointers per se, it's the initialization of a pointer to a string literal. A string literal in C++ is defined as an array …

Member Avatar for Narue
0
115
Member Avatar for ThatOtherGuy

Rather than bump your thread (which is exceptionally rude), why not show us what you've managed to find in the last [B]three months[/B] that helps solve your problem. If you've done nothing to help yourself aside from "gimme gimme gimme!" then I won't waste my time with a lost cause.

Member Avatar for Ezzaral
0
114
Member Avatar for AceofSpades19

It depends on which makes more sense at the application level. I tend to work front end to back end in my designs. Writing and using the interface first helps one to understand and better design the implementation.

Member Avatar for mustafaneguib
0
99
Member Avatar for smnadig

>Can anybody help me with an efficient C-Algorithm for this conversion? printf directly supports printing characters, decimal, and hexadecimal, so that's easy. Converting between ASCII and EBCDIC is also easy and highly efficient if you use two conversion tables: [code=c] unsigned char ascii[] = { /* All characters in ASCII …

Member Avatar for ArkM
0
1K
Member Avatar for apaciboy

This sounds like homework, so until you show some effort, I'm going to give you the obligatory "Go do it yourself, slacker!" answer.

Member Avatar for Narue
0
82

The End.