1,118 Posted Topics

Member Avatar for galmca
Member Avatar for scru

He didn't misunderstand. There are two ways to look at "inline": 1. the OP wants to avoid using function call syntax 2. AD's code actually avoids calling a function Either way the best solution takes multiple lines of code, as posted.

Member Avatar for Student level
0
476
Member Avatar for catdieselpow

You'll have to give an effort yourself first. You'll have to create a function that takes as argument a 2D vector: [inlinecode]void fillVectorOfVector( vector< vector<double> > &v )[/inlinecode] The code in [B]printVectorOfVector()[/B] should help you there. To generate random numbers see [URL="http://www.daniweb.com/forums/thread1769.html"]here[/URL]. Post again with what you come up with, …

Member Avatar for nana121
0
127
Member Avatar for helpingdeed

All user input is terminated by pressing the ENTER key. Users expect this. If you want to get individual key presses, you must do an OS-specific thing: disable buffered input. On Windows, use [URL="http://www.google.com/search?btnI=1&q=msdn+setconsolemode"][b]SetConsoleMode[/b]()[/URL]. On POSIX, use [URL="http://linux.die.net/man/3/tcsetattr"][b]tcsetattr[/b]()[/URL]. Be sure that you only do this when the user expects it, …

Member Avatar for Duoas
0
116
Member Avatar for cosmos22

You need to get a good Win32 reference. The function you want is [inlinecode]BOOL RemoveDirectory( LPCTSTR lpPathName );[/inlinecode] The directory must be empty and your program must have permissions to delete it. If the function fails it returns zero, else it returns non-zero. Hope this helps.

Member Avatar for nicesiddeeq
0
219
Member Avatar for yap.nice

There is nothing more or less hard about C++ than any other programming language. People fear C++ because it comes with a very [i]large[/i] set of capabilities. It can be used to program procedurally. It can be used to program object-orientedly. It can be used to program generically. It can …

Member Avatar for akilank
0
159
Member Avatar for Kartik_shashank

> On the plus side, being DOS, you can generate simple low-resolution graphics (which a true Win32 console cannot). Actually, if you get the DC of the console window, you can draw on it like any other. Unfortunately, it is impossible to use a window proc on the console window... …

Member Avatar for gowthamsettu
0
1K
Member Avatar for Duoas

Hi all. I have some questions that may cover multiple forums, but I think this is the most appropriate. I have been working on my wife's new website. You can see its current state here: [url]http://home.comcast.net/~mlyn7576/signandgrow/[/url] The following questions apply both to the home page and one of the sub-pages. …

Member Avatar for ivatanako
0
148
Member Avatar for tomtetlaw

You need to read up at [URL="http://www.newty.de/fpt/"][b]The Function Pointer Tutorials[/b][/URL] Good luck!

Member Avatar for NathanOliver
0
130
Member Avatar for rafikul

More explicitly, even though [inlinecode]int a[5];[/inlinecode] and [inlinecode]int *a;[/inlinecode] both declare [B]a[/B] to be a pointer to an integer, the first is [I]constant[/I], meaning that you cannot change the value of [B]a[/B] (it cannot be used as an lvalue). You will save yourself some accidental grief if you keep different …

Member Avatar for peter_budo
0
183
Member Avatar for d0ugg

[color=green]You need to be just a little more careful with names[/color] [B]Insertion()[/B] is a bad name because it is not obvious that it sorts the list. [B]InsertionSort()[/B] is a good name. [B]Destroy()[/B] is not a good name because it doesn't destroy your object; it only deletes every item in the …

Member Avatar for ssuss
0
146
Member Avatar for eDeloa

You can't initialize it inside the class definition. Do this instead: [code=C++] class Test { public: static const string MYARRAY[]; }; const string Test::MYARRAY[] = {"hello", "world"}; [/code] Have fun!

Member Avatar for kvprajapati
0
2K
Member Avatar for zoner7

If I remember correctly the Foo tutorials instruct you to get the pre-compiled binary DLLs. It should have come with some header files. Did you put them in the include path? Did you tell VC++ where to find the lib files? Did you link with the SDL DLL?

Member Avatar for thriek
0
270
Member Avatar for iarmza

Please use [[B][/B]code] [[B][/B]/code] tags. It looks like you are off to a fairly good start, but you are missing a couple things. Remember, in Pascal multiple statements [I]must[/I] be enclosed in a [b]begin[/b]..[b]end[/b] block. Also, make sure you get a good reference. It looks to me like you are …

Member Avatar for Nick Evan
0
213
Member Avatar for techie929

This is the C++ forum, not the C forum. You cannot expect C answers in a C++ forum. Nevertheless, [b]AD[/b] [i]did[/i] answer your question sufficiently. The answer works the same way, except you use a FILE* instead of an istream. If you can use FILE*s, you can do it. Please …

Member Avatar for Duoas
0
592
Member Avatar for moein_soltani

You've pretty much learned all there is to it: the STL streams library does not handle non-[b]binary[/b] streams very well. If you plan to [b]seek[/b][[b]g[/b]|[b]p[/b]]() / [b]tell[/b][[b]g[/b]|[b]p[/b]]() at all, use binary I/O. Sorry.

Member Avatar for moein_soltani
0
246
Member Avatar for MrYrm
Member Avatar for MrYrm
0
173
Member Avatar for mikabark

It is not entirely clear what you want to do, but if it is just copying specific elements of a container to another container, use the [b]remove_copy_if[/b]() STL algorithm, along with a predicate that decides what it is you wish to [i]not[/i] copy, and a [b]back_insert_iterator[/b]<> to stick the results …

Member Avatar for mikabark
0
327
Member Avatar for rsaska

No exception is thrown when you enter bad input. Instead, the input stream is set to a [i]fail state[/i]. Check using the [b]good[/b]() member function. [code=C++] int n; cout << "Enter a number: " << flush; while (true) { cin >> n; if (!cin.good()) { cin.clear(); // clear the error …

Member Avatar for rsaska
0
78
Member Avatar for hag++

Your professor is a jerk. (Anyone who would instruct his students to do something before doing it himself [i]the same way students would[/i] is a jerk.) Using [inlinecode]system( "color 1B" );[/inlinecode] [i]doesn't work[/i] -- that modifies the color of the [i]entire console window[/i]. Since you are on Windows, there are …

Member Avatar for hag++
0
572
Member Avatar for clayton797

Whenever you get errors, it is typically a good idea go to the line with the error on it. On line 63 you have: [code=C++ firstline=63] cout<<"The paycheck for the salesperson will be approximately ">>payCheck>>" " [/code] The error message says it has a problem with '>>' on that line. …

Member Avatar for Duoas
0
469
Member Avatar for Begjinner

It has to do with what type of character input the [I]compiler[/I] expects and what kind of character data your [I]program[/I] expects. Surprisingly, the two may be different. Unfortunately, anything outside the ASCII range (0..127) is not safe to put in a string/character literal. Alas.

Member Avatar for Duoas
0
137
Member Avatar for Jennifer84

The typical way to handle this is to create a hidden parent window for the whole application. All other top-level windows are children of this parent window, so no extra taskbar buttons are created for them. To quote the MS docs under [B]Visibility of Taskbar Buttons[/B] [quote]A taskbar button is …

Member Avatar for scott.vass
0
142
Member Avatar for SpyrosMet

What you want to do is not something that is addressed by the C or C++ standards: you must use OS-specific code or special extensions. On Windows (which you are using if you are using Dev-C++), you should use the [URL="http://www.google.com/search?btnI=1&q=msdn+WaitForSingleObject"][b]WaitForSingleObject[/b]()[/URL] function. Use [URL="http://www.google.com/search?btnI=1&q=msdn+GetStdHandle"][b]GetStdHandle[/b]()[/URL] to get the first argument. You'll …

Member Avatar for Duoas
0
210
Member Avatar for vlove_3008

You need to either run your program from the command prompt, or put some form of pause at the end of your program. For example: [code=C++] #include <iostream> #include <limits> using namespace std; int main() { // This is my program cout << "Hello world!\n\n\n"; // This keeps the console …

Member Avatar for Duoas
0
165
Member Avatar for FatimaRizwan

[i]Don't[/i] use [b]strtok[/b](). It is for handling C-strings (not [b]std[/b]::[b]string[/b]s), and it modifies the string. Use the [b]find_first_of[/b]() and [b]substr[/b]() string member functions instead. Hope this helps.

Member Avatar for jonsca
0
447
Member Avatar for Agni

You need to specify the standard you are compiling against. The GCC defaults to using its own extensions. [inlinecode]g++ -Wall -ansi -pedantic ...[/inlinecode] Hope this helps.

Member Avatar for Agni
0
139
Member Avatar for chotib

I've only used these things in [b]Delphi[/b], but it looks right to me. The only concern I have is based upon your error message: what kind of thing is [b]OpenDialog1[/b]? Is it a [i]pointer[/i] to a [b]TOpenDialog[/b]? (And not an direct object or a reference?) Is it [i]visible[/i] in the …

Member Avatar for chotib
0
250
Member Avatar for ge6a93

The [b]BitBlt[/b]() function doesn't resize images. You need [URL="http://www.google.com/search?btnI=1&q=msdn+StretchBlt"][b]StretchBlt[/b]()[/URL]. It does a really bad job, btw, so it might be worth your while to use an external library to do image transformations. Hope this helps.

Member Avatar for Duoas
0
77
Member Avatar for m7md.is

He has [inlinecode]#include <windows.h>[/inlinecode], so I believe we can safely assume some things about his operating environment. On Windows, to wait for an event with a timer, use [URL="http://www.google.com/search?btnI=1&q=msdn+WaitForSingleObject"][b]WaitForSingleObject[/b]()[/URL] with the console input handle specified as the signal object. You'll need to use [URL="http://www.google.com/search?btnI=1&q=msdn+GetStdHandle"][b]GetStdHandle[/b]()[/URL]. [code=C++] bool countdown( int& seconds ) …

Member Avatar for m7md.is
0
224
Member Avatar for Amol Ranjere

Wait, is this a console (text) program or a Windows (GUI) program? In either case, you will have to add "event listeners": code that checks for input from the keyboard and the mouse. If a button is pressed, add the appropriate digit into the current number or invoke the appropriate …

Member Avatar for SideTruth
0
123
Member Avatar for vrnadh123

Er, yeah. It's one of those naming things. A virtual partition is so called because it doesn't necessarily correspond to physical structures. It's not hidden though. [EDIT] but I think it can be... [/EDIT]

Member Avatar for amol_d
0
197
Member Avatar for DarkC0de

^D terminates input. Hence, you cannot read it from the terminal directly (unless you modify the terminal's input state -- which I don't recommend). If you are sure you are reading from the terminal, you can simply say: [code=C++] string text; cout << "Please enter a bunch of lines. Press …

Member Avatar for DarkC0de
0
774
Member Avatar for Dave Sinkula

I know this is old, but anyway... I've always preferred a simple variation of [B]bar()[/B]: [code=C] unsigned char rev( unsigned char b ) { unsigned char result = 0; while (b) { result <<= 1; result |= b % 2; b >>= 1; } return result } [/code] This method …

Member Avatar for Dave Sinkula
3
770
Member Avatar for mythili_sharon

Answers like: [quote]Which is equivalent to [inlinecode]n = n + 1;[/inlinecode] [list=1] [*][inlinecode]++n;[/inlinecode] [*][inlinecode]n++;[/inlinecode] [/list] [/quote]are meaningless. They are the same. A better answer is: [quote]What is the difference between: [list] [*][inlinecode]x = n++;[/inlinecode] [*][inlinecode]x = ++n;[/inlinecode] [/list] [/quote] Once that is understood then you can get into stuff like …

Member Avatar for manishanibhwani
0
140
Member Avatar for Androggles

To delete files in other directories, you must provide path information. An [b]absolute[/b] path doesn't care where your executable is: [quote]C:\WINDOWS\Media\chimes.wav /usr/bin/env[/quote](Don't delete either of those, btw.) A [B]relative[/B] path is relative to the current working directory (which may or may not be where your executable is -- it is …

Member Avatar for Androggles
0
223
Member Avatar for ge6a93

Wait... are you writing a [i]GUI[/i] application or a [i]console[/i] application? To me, MFC Dialog == GUI --> put a "[B]next[/B]" button on your form, and don't mess with [B]GetKeyboardState[/B]().

Member Avatar for Duoas
0
119
Member Avatar for Duoas

Hi all. I've nearly finished the home page for my wife. Sadly, I've discovered (again, surprise, surprise) IE doesn't play fair. I wanted the home page to be a simple "splash with links" kind of thing, and I used a variation of Meyer's CSS popup technique to do it. (See …

0
71
Member Avatar for Geek-Master

Essentially, yes. Except a pointer goes one step further than a magic number: it is the index of an actual memory location.

Member Avatar for new programer
0
490
Member Avatar for Duoas

Hi all. I am designing a website for my wife's business, and I am coding it by hand -- pure HTML 4.01 Strict and CSS-1. When I loaded it into IE 6 (6.0.2900.5512.xpsp_sp3_gdr.090804-1435) I got a message complaining that it had "Active Content". (I am aware it is a result …

Member Avatar for Duoas
0
113
Member Avatar for satya.vijai

The answer actually depends on which version of Windows you are using. Also, since this is a batch file, you want to suppress questions like "Do you really want to delete X?", which will really confuse and frighten your end-user. Here's a batch that [I]should[/I] work on all versions of …

Member Avatar for JenniC
-1
2K
Member Avatar for m610

Unfortunately, there really isn't a very amazing way to do directory browsing natively. That aside, there is also useful information like this: [URL="http://delphi.about.com/od/windowsshellapi/l/aa122803a.htm"][b]Centering the Select Directory dialog[/b][/URL] at [b]about.com[/b]. Enjoy!

Member Avatar for BitFarmer
0
4K
Member Avatar for RohitSahni

That depends. What I/O interface are you using? Is it a console process? Are you using a GUI? What OS? What widget set?

Member Avatar for shashanderson
0
241
Member Avatar for tifka

What OS are you using? If it is x86 google "dos interrupt 21h". If you are on a MIPS processor you'll need to google "mips syscall". Hope this helps.

Member Avatar for Goalatio
0
316
Member Avatar for Duoas

First off, C++ does not know anything about the I/O device you are using. It can be a keyboard and monitor, or a file, or a network connection, or anything which can do I/O. What that means is that there is no standard way to do this in C++. That …

Member Avatar for Duoas
0
452
Member Avatar for Duoas

First off, C does not know anything about the I/O device you are using. It can be a keyboard and monitor, or a file, or a network connection, or anything which can do I/O. What that means is that there is no standard way to do this in C. That …

Member Avatar for dangana
0
229
Member Avatar for vegaseat

Nice. The only problem is that you can have overflow, which would destroy the values of the variables. Use bitwise operations instead: [code=C++] a ^= b; b ^= a; a ^= b; [/code] Enjoy.

Member Avatar for Duoas
0
224
Member Avatar for Samran

The [URL="http://linux.die.net/man/2/wait"][b]wait[/b]()[/URL] function monitors the state of a [i]process[/i], not its I/O streams. What you really want is the [URL="http://linux.die.net/man/2/poll"][b]poll[/b]()[/URL] or [URL="http://linux.die.net/man/2/select"][b]select[/b]()[/URL] function. It also seems that you want [b][i]unbuffered[/i][/b] input on your end of the pipe. See [URL="http://linux.die.net/man/3/termios"]termios(3)[/URL] for more. See also [URL="http://linux.die.net/man/3/poll"]poll(3)[/URL] and [URL="http://linux.die.net/man/3/select"]select(3)[/URL] for good reading on …

Member Avatar for sathish_s
0
237
Member Avatar for amazing_grace

It is because you have misunderstood something. A [b]string[/b] is not a simple POD type -- it is an [b]object[/b] type -- which you cannot write directly to file (according to Delphi standards [and also ISO standards, but that's beside the point ;) ]). The [b]write[/b][[b]ln[/b]] functions know how to …

Member Avatar for Duoas
0
350
Member Avatar for dzhugashvili

A [b]std[/b]::[b]vector[/b] is guaranteed to maintan contiguous data space -- meaning it cannot handle [i]really large[/i] data. Use a [b]std[/b]::[b]deque[/b] instead. I looks much the same, but the data need not be stored contiguously -- meaning it can handle a great deal larger amount of data (because it can work …

Member Avatar for Ancient Dragon
0
144

The End.