1,174 Posted Topics

Member Avatar for jaku78

Try asserting your indices (everywhere) .. [CODE] #include <assert.h> while ( i < m ) { for (j=0;j<in;j++,l++,i++) { /* rows and cols are your allocated dimensions ... */ assert(k >= 0 && k < rows); assert(l >= 0 && l < cols); a[k][l]=i; } [/CODE]

Member Avatar for mitrmkar
0
147
Member Avatar for txwooley

>> My rand() isn't very random. As a matter of fact, it's not random at all! >> I get the same result every time on both computers: 180428383 This is by design, you want to [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/srand/"]Initialize random number generator[/URL].

Member Avatar for Fbody
0
97
Member Avatar for yuri1969

>> How should I initiate the str_month, I thought that line #12 initiation is sufficient [URL="http://www.cplusplus.com/reference/clibrary/cstring/strncpy/"]strncpy()[/URL] does not necessarily NULL-terminate the string -- so, you might do e.g. .. [code] str_month[3] = '\0'; [/code]

Member Avatar for yuri1969
0
960
Member Avatar for bufospro

>> But when I am trying to pass this value to my struct and then to print it it does not work. You have forgotten the [ICODE]%s[/ICODE] format specifier, so .. [CODE] strcpy( myaccounts->allaccounts[myaccounts->pos].name,name); /* %s embedded in the format string */ printf("Name = %s\n",myaccounts->allaccounts[myaccounts->pos].name); [/CODE] >> And another question …

Member Avatar for dgreene1210
0
154
Member Avatar for tech9x

>> ... tokenize my string, which is read from a file, but my output is blank, why? There could be many reasons for no output at all - was the file opened, what's in it etc. You could get a bit creative and display what you read from the file …

Member Avatar for tech9x
0
2K
Member Avatar for WildBamaBoy

>> Why doesn't it accept the filename I give it? [URL="http://www.cplusplus.com/reference/iostream/fstream/open/"]open()[/URL] only accepts a [ICODE]const char *[/ICODE], so you have to use [ICODE]c_str()[/ICODE] .. [code] file.open(filename.c_str()); [/code] In your original post, you are calling [ICODE]main()[/ICODE] recursively - it's a poor practice and also forbidden. You could instead devise a regular …

Member Avatar for WaltP
0
358
Member Avatar for therobot

The code you've posted seems to be OK, so if the problem still persists, go ahead and post all of the code.

Member Avatar for therobot
0
2K
Member Avatar for Violet_82

>> 'ofstream': No such file or directory": The C++ header files are listed in this [URL="http://www.cplusplus.com/reference/"]Reference[/URL].

Member Avatar for Violet_82
0
198
Member Avatar for onus

You might go through a [URL="http://www.newty.de/fpt/fpt.html"]function pointer tutorial[/URL].

Member Avatar for mitrmkar
0
117
Member Avatar for lais90

[QUOTE=lais90]my os is windows 7, and I think it is support conio.h So how could I use conio.h to edit my color?[/QUOTE] Even if your compiler has <conio.h> in some form or another, I doubt you'll find anything like you want in it. Hence I'd suggest that you forget about …

Member Avatar for mitrmkar
0
714
Member Avatar for rothn

>> a error message is triggered which says "The operation completed successfully." This happens because you are using [ICODE]FormatMessage()[/ICODE] incorrectly. See [URL="http://msdn.microsoft.com/en-us/library/ms680582%28v=VS.85%29.aspx"]Retrieving the Last-Error Code[/URL]. Note how the value returned by [ICODE]GetLastError()[/ICODE] is passed to [ICODE]FormatMessage()[/ICODE].

Member Avatar for vijayan121
0
1K
Member Avatar for namasee

@namasee: You must have missed the Daniweb Rules .. [QUOTE=DaniWeb Rules] Keep it Clear * Do post in full-sentence English [/QUOTE] About the books, there is a lengthy sticky thread --> [URL="http://www.daniweb.com/forums/thread70096.html"]C++ Books[/URL]

Member Avatar for mitrmkar
0
96
Member Avatar for phfilly

"Selected" is initially an uninitialized pointer (read: it is [I]garbage[/I]). Unless it gets assigned inside the loops, [ICODE]ValidMove()[/ICODE] receives garbage. I think that instead of assuming that everything works as you think it should, you should verify that this actually is the case here, so how about ... [code] void …

Member Avatar for phfilly
0
155
Member Avatar for hermann87

[QUOTE=hermann87;1117788] I've added the .lib and header files under Project->Linker Dependencies and Project and Solutions->VC++ Directories (where I added library files for x64 and header files) but still nothing.[/QUOTE] As far as I know Visual Studio 2008 [B]Express[/B] Edition does not support 64-bit programs. However, by installing the correct Windows …

Member Avatar for shijobaby
0
352
Member Avatar for Lord_Migit

One more issue not yet mentioned, please the comments .. [code] void GeneticAlgorithm::RouletteWheelSelection() { int iRandomNumber, iTotalFitness; CalculateTotalFitness(iTotalFitness); CreatePie(); for(unsigned long int i=0; i<m_iPopDensity; i++) { GenerateRandomNumber(iTotalFitness, iRandomNumber); for(unsigned long int j=m_iPopDensity - 1; j >= 0; j) { if(iRandomNumber > m_vPopulation2[j]->m_iCumulativeFitness) // Assuming j == 0 here ... j--; …

Member Avatar for Fbody
0
678
Member Avatar for triumphost

[QUOTE=triumphost;1165712]I have a button caption, i know its a button and i have its handle...[/QUOTE] Are you sure about that? [ICODE]FindWindowxx()[/ICODE] may very well return NULL. So, first thing to do, would be to add code that checks that you actually receive handles to those windows. Upon failure, you may …

Member Avatar for WilliamW1979
0
191
Member Avatar for Suzie999

>> .. my head is just spinning If the libraries seem daunting, you might check out a basic MSDN CryptoAPI example [URL="http://msdn.microsoft.com/en-us/library/aa382380%28v=VS.85%29.aspx"]Creating an MD5 Hash from File Content[/URL].

Member Avatar for Suzie999
0
668
Member Avatar for mommabear

>> float CDROM::ReturnCost(void) [COLOR="Red"]const' : overloaded[/COLOR] member function [COLOR="Red"]not found[/COLOR] in 'CDROM' It's saying that the function declaration/definition signatures are not matching wrt. your [ICODE]const[/ICODE] usage, so you want to have .. [code] class CDROM { ... float ReturnCost() const; // <--- const was missing // The same thing for …

Member Avatar for mitrmkar
0
152
Member Avatar for DrueY

The code has been compiled with a compiler that supports variable length arrays, Microsoft's C compiler does not and probably never will support that feature. You can work around this with a simple [ICODE]#define[/ICODE], like so [code] #define NAME_OF_YOUR_CHOICE_HERE 8192 /* int n = 8192; */ ... int main() { …

Member Avatar for DrueY
0
317
Member Avatar for karpe

In your code the following cast is [COLOR="Red"]wrong[/COLOR] [code] for (j=0; j<BYTES; j++) printf("[%02X]\n", (const unsigned char [COLOR="Red"]*[/COLOR]) data[j]); [/code] Could you post the complete compilable code which demonstrates the working and non-working behaviour. I think your problem eventually relates to the default [ICODE]char[/ICODE] being signed.

Member Avatar for karpe
0
186
Member Avatar for ItecKid

In addition to what nezachem stated, it looks like you are also simply exploding the stack with your buffer declaration [code] char buffer [INT_MAX]; [/code]

Member Avatar for ItecKid
0
2K
Member Avatar for ace8957

Basically you are pushing the left-hand side of the string onto the stack and then comparing that data with the very same left-hand side of the string. The right-hand side of the string is not involved in the comparisons.

Member Avatar for ace8957
0
235
Member Avatar for avataralien
Member Avatar for shibblez
0
569
Member Avatar for blessedboy123

>> output becomes full of INF INF INF 100 times :-) You have to initialize the [ICODE]sum_*[/ICODE] variables.

Member Avatar for mitrmkar
0
102
Member Avatar for Jsplinter

It looks like it ought to work as such. However, you could check that; [LIST] [*] You have the [ICODE]ON_WM_TIMER()[/ICODE] macro in the dialog class' message map. [*] [ICODE]SetTimer()[/ICODE] succeeds (returns a nonzero value). [*] [ICODE]UpdateData()[/ICODE] succeeds (returns a nonzero value). [/LIST]

Member Avatar for Jsplinter
0
1K
Member Avatar for Fbody

Though I might be missing something here, but anyhow, I think changing the comparison functions to [icode]static[/icode] would be in order here, so you'd have: [code] static bool Descending(const pair<const T, int> &, const pair<const T, int> &); sort(mode.begin(), mode.end(), &Statistics::Stats<T>::Descending); [/code] P.S. Why the [icode]const[/icode] in the vector declaration …

Member Avatar for Fbody
0
3K
Member Avatar for phfilly

>> RNInterpreter.C:8: note: (perhaps a semicolon is missing after the definition of ‘Thousand’) Your compiler is suggesting that Thousand.h looks like [code] class Thousand { // All your Thousand stuff here ... } // <--- ... but no ending semicolon after the curly bracket [/code]

Member Avatar for phfilly
0
203
Member Avatar for Kunal Aggarwal

You want [code] m_strLine.Replace("\n", "\r\n"); [/code] >> m_strLine.Replace ( '\n' , [COLOR="Red"]'\r\n'[/COLOR] ); [COLOR="red"]That[/COLOR] should give you a warning or two, are you ignoring compiler warnings?

Member Avatar for Kunal Aggarwal
0
198
Member Avatar for sonsofliberty84

>> it also displays the two parent directories, '.' and '..'. Line #30 stores both "." and ".." in addition to the directory and file names, so you have to work around that.

Member Avatar for sonsofliberty84
0
97
Member Avatar for Suzie999

If you are on Windows, then look into [URL="http://msdn.microsoft.com/en-us/library/aa364418%28VS.85%29.aspx"]FindFirstFile()[/URL]. As the documentation states, you can use wildcards in the file/path name, e.g. "c:\\foo\\bar\\*.txt".

Member Avatar for Suzie999
0
91
Member Avatar for Danny_501

>> when I type 'q' into the command line it should enter that if statement, but it doesn't. [icode]fgets()[/icode] stores the newline in the buffer, whenever there's enough room to do that. So, you are actually comparing [icode]strcmp("q", "q\n")[/icode], which apparently returns non-zero. You might use e.g. [URL="http://www.cplusplus.com/reference/clibrary/cstring/strcspn/"]strcspn()[/URL] to get …

Member Avatar for myk45
0
672
Member Avatar for sree_ec

>> regarding latest c std You might be interested in [URL="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf"]the latest draft[/URL] Perhaps also see [URL="http://www.open-std.org/jtc1/sc22/wg14/www/standards"]C - Approved standards[/URL]

Member Avatar for itpungaraja
0
239
Member Avatar for MWE_QUE

>> Now I'll work on the fibonacci function. You need to initialize [icode]j[/icode] before using it - since it's an automatic variable, it is NOT initialized to zero by the compiler.

Member Avatar for MWE_QUE
0
127
Member Avatar for glenak

You are probably just doing something wrong or having a configuration issue. You might refer to Eclipse's Help and/or post in a dedicated [URL="http://www.eclipse.org/forums/index.php?t=i&cat=6&S=3fdffc50ca1404220a8bbc1ecbd4eb13"]Eclipse forum[/URL].

Member Avatar for kes166
0
126
Member Avatar for burcin erek

>> searching does not work pls help You should be much more specific as to what is not working. You might read Narue's [URL="http://www.daniweb.com/forums/thread78223.html"]Read This Before Posting[/URL] - especially the section [B]Describe your problem clearly and fully![/B].

Member Avatar for burcin erek
0
204
Member Avatar for yingfo

Maybe I'm misunderstanding the problem .. but if not, then you might store the points clicked in a container (e.g. vector<point>). So that upon drawing, you iterate over the container, drawing every point stored thus far.

Member Avatar for nbaztec
0
169
Member Avatar for myk45

Apparently you are accessing memory to which you have read-access. Generally, there are no built-in safety nets with regards to e.g. reading/writing out of array bounds and other things alike - you just have to be careful.

Member Avatar for myk45
0
317
Member Avatar for Jack_1

If you have MS Word, then open the document in Word and do a Find/Replace, replace two adjacent spaces with a single space.

Member Avatar for mitrmkar
0
129
Member Avatar for sabareesh

>> how can get path of specified exe file? What does [I]specified[/I] mean here? If you need to know the path of your running program, then use [URL="http://msdn.microsoft.com/en-us/library/ms683197%28VS.85%29.aspx"]GetModuleFileName()[/URL].

Member Avatar for mitrmkar
0
64
Member Avatar for glenc70

I think it goes along the lines of .. [code] // Get current style LONG dwStyle = GetWindowLong(hWnd, GWL_STYLE); // Drop WS_SYSMENU dwStyle &= ~WS_SYSMENU; // Apply current style SetWindowLong(hWnd, GWL_STYLE, dwStyle); [/code] and immediately after that, use [URL="http://msdn.microsoft.com/en-us/library/ms633545%28VS.85%29.aspx"]SetWindowPos()[/URL] speficying the SWP_FRAMECHANGED flag. Although, note that this also gets rid …

Member Avatar for mitrmkar
0
78
Member Avatar for jay1648

[QUOTE=N1GHTS][b]Person person = *p1;[/b] This is copying the pointer address to the first 4 bytes of [b]firstName[/b] in the newly created instance of [b]Person[/b], and then completely undone by line 27: [/QUOTE] Sorry, but that is actually not so. [b]Person person = *p1;[/b] does a struct assignment, i.e. copying [icode]sizeof(Person)[/icode] …

Member Avatar for N1GHTS
0
2K
Member Avatar for unnamed17

See GetPrivateProfilexxxxxx()/WritePrivateProfilexxxxxx() functions in [URL="http://msdn.microsoft.com/en-us/library/ms724875%28v=VS.85%29.aspx"]MSDN[/URL]

Member Avatar for N1GHTS
0
97
Member Avatar for freda173

>> problem is getting the filename from the switch function back into the main In order to do that, you need to pass in the address of the pointer (filename) that you will be setting inside this setup() function. C [I]passes arguments by value[/I], i.e. generally arguments passed to a …

Member Avatar for freda173
0
159
Member Avatar for ashishchoure

In your first case, [icode]pDerived[/icode] ends up being a NULL pointer. When you call [icode]TestD()[/icode] through it, the [I]this[/I] pointer will also be NULL (inside [icode]TestD()[/icode]) - hence the crash. In the latter case, you are trashing memory worth of two ints approximately where your allocated Base object is stored …

Member Avatar for Fbody
0
123
Member Avatar for burcin erek
Member Avatar for ganesh_IT

Don't set [icode]m_pMainWnd[/icode] to point to the dialog object, because during the execution of [icode]DoModal()[/icode], MFC does a [icode]PostQuitMessage()[/icode] via the dialog's [icode]OnNcDestroy()[/icode] (if [icode]m_pMainWnd[/icode] points to the window being destructed). So, the program terminates as soon as the posted [icode]WM_QUIT[/icode] gets extracted from the message queue, even though you've …

Member Avatar for mitrmkar
0
121
Member Avatar for aman rathi

>> i am not receiving any output i pressed ctrl+f9 If you are saying that CodeLite actually fails to run the compiler altogether, then it's probably best to post in [URL="http://www.codelite.org/forum/viewforum.php?f=3"]CodeLite forum[/URL].

Member Avatar for usagi
0
275
Member Avatar for Nathaniel10

>> The last output to the screen is the prompt to enter the name of the output file. Once you've gotten out of the initial while() loop, I believe you use Ctrl+Z to stop entering coordinates, [icode]cin[/icode] has eof bit set, which you must [URL="http://www.cplusplus.com/reference/iostream/ios/clear/"]clear()[/URL] before trying to get any …

Member Avatar for Nathaniel10
0
157
Member Avatar for daviddoria

[icode]dynamic_cast<CTriangle*>(ppoly1)[/icode] gives you a NULL pointer, through which the call gets made. If you were to modify the (non-existent) object's state inside the [icode]triFunc()[/icode], then you would get a run-time error, but because you just return the constant value (5), it appears to 'work'.

Member Avatar for mitrmkar
0
118
Member Avatar for ftl25

>> How do I check if a member of a struct is null? Just like you are doing, i.e. [CODE] // Is it a NULL pointer? if(ErrorInfo->TestName != NULL) { // No it isn't ... } [/CODE] >> debug shows it as 0xccccccc, "") This value [icode]0xccccccc[/icode] tells you that …

Member Avatar for ftl25
0
10K

The End.