2,384 Posted Topics

Member Avatar for alone2005

[QUOTE=alone2005]But now I am even more confused, cause this function is only defined but has never been used, how could it cause a memory fault? help pls?[/QUOTE]As usual, the answer is probably in the code that you haven't show. Try paring the code down to a minimum that demonstrates the …

Member Avatar for alone2005
0
143
Member Avatar for Mahen

If you're trying to concatenate "cmd.exe" with some further information, why not use [FONT=Courier New]snprintf[/FONT]? [code]#include <stdio.h> int main() { char command[200], filename[] = "filename"; int result = snprintf(command, sizeof command, "cmd.exe %s", filename); if ( result >= 0 && result < sizeof command / sizeof *command ) { puts(command); …

Member Avatar for winbatch
0
620
Member Avatar for joeh157

Let's start slow.[QUOTE=joeh157]Can anyone help with a program that would allow you to enter 5 floating point values into an array called Marks and then calculate and displays the average of the marks entered?[/QUOTE]Do you know how to input a single number (show code if so)? Do you know how …

Member Avatar for Dave Sinkula
0
178
Member Avatar for alone2005

[url]http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.11[/url] Moral: don't put the definition in the header. [edit]And [FONT=Courier New]do[/FONT] is a keyword.

Member Avatar for Dave Sinkula
0
254
Member Avatar for chriswell

[QUOTE=1o0oBhP]sizeof letters: needs brackets around letters[/QUOTE]No, you don't. You need parentheses for a type, but not an object. [QUOTE=1o0oBhP]when initialiseing the frequency table you would need to set every element to zero to be sure, you have only set the first. using a loop is a much better idea.[/QUOTE]Wrong again. …

Member Avatar for bgunn
0
218
Member Avatar for Jon182
Member Avatar for Kob0724

Dev C++ doesn't like the `linesolver(a, b, c, y, d, e[SIZE=+1],)`What am I doing wrong? Get rid of the extra comma. (And the line should end in a semicolon, but in the whole code this is already so.)

Member Avatar for Kob0724
0
333
Member Avatar for zerenoa
Member Avatar for shakesahal
Member Avatar for jepapel

I'd use an array so you could use subtraction to find the letter. [code]#include <iostream> int main ( void ) { static const char alphabet[] = "abcdefghijklmnopqrstuvwxyz"; int input; while ( std::cin >> input ) { std::cout << alphabet [ (input - 1) % (sizeof alphabet - 1) ] << …

Member Avatar for zyruz
0
300
Member Avatar for gagan

Not my strong suit here, but isn't [FONT=Courier New]f()[/FONT] inherited by both [FONT=Courier New]b[/FONT] and [FONT=Courier New]c[/FONT] since it is public in [FONT=Courier New]a[/FONT]? And as such, there is ambiguity between which [FONT=Courier New]f()[/FONT] you are calling: [FONT=Courier New]b::f()[/FONT] or [FONT=Courier New]c::f()[/FONT]? I found this would remove the ambiguity.[code] w.b::f();[/code]Or.[code] …

Member Avatar for gagan
0
322
Member Avatar for nihar_29
Member Avatar for cpp noob

[QUOTE=Narue]>what does "Kisama wa akan da!" mean? You probably don't want to know. ;)[/QUOTE]Is it anything like one of my favorite quotes from [I]Married... With Children[/I]?[quote]... And this is the river the Indians used to call [I]KissYourWhiteAssGoodbye[/I].[/quote] :p [edit]The episode had something to do with whitewater rafting.

Member Avatar for Dave Sinkula
0
269
Member Avatar for Quickslvr

First figure out how to tell the first character of a word. [code]#include <stdio.h> #include <ctype.h> int main(void) { char *ch, text[] = "The quick brown fox jumps over the lazy dog."; int word = 0; for ( ch = text; *ch; ++ch ) { if ( isalpha(*ch) ) { …

Member Avatar for aismm
0
6K
Member Avatar for winbatch

I didn't see the issue, but WRT a C version I think it would be something like this. [code]#include <stdio.h> #include <stdlib.h> int main(void) { static const char filename[] = "file.txt"; FILE *file = fopen(filename, "rb"); if ( file ) { char *buffer; long size; fseek(file, 0, SEEK_END); size = …

Member Avatar for winbatch
0
316
Member Avatar for karen_CSE

[url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1045691686&id=1043284392[/url]

Member Avatar for Dave Sinkula
0
64
Member Avatar for Kazastankas

Add the int to some known iterator? [code]#include <iostream> using std::cout; using std::endl; #include <vector> using std::vector; #include <algorithm> using std::copy; #include <iterator> using std::ostream_iterator; int main() { static const int init[] = {10,20,30,40,50,60,70,80,90,100}; vector<int> v(init, init + sizeof init / sizeof *init); copy(v.begin(), v.end(), ostream_iterator<int>(cout, " ")); cout << …

Member Avatar for Dave Sinkula
0
113
Member Avatar for Decessus

This is a forum for help with C or C++ programming. There is an announcement or two at the top of it.

Member Avatar for Dave Sinkula
0
246
Member Avatar for Kazastankas

Why not a vector of vectors (of vectors...)? Your profiling indicated performance requirement issues?

Member Avatar for Kazastankas
0
175
Member Avatar for desidude

[url=http://www.daniweb.com/techtalkforums/announcement8-2.html]We only give homework help to those who show effort[/url] Searching the C and C++ Code Snippets might prove useful. So might doing a Google search on [FONT=Courier New]std::hex[/FONT].

Member Avatar for Kazastankas
0
265
Member Avatar for alone2005

[code] inline [COLOR=Red]const[/COLOR] string getHandle(){return cHandle;}[COLOR=Magenta];[/COLOR] inline [COLOR=Red]const[/COLOR] int getPara(int i){return cPara.at(i);}[COLOR=Magenta];[/COLOR] inline [COLOR=Red]const[/COLOR] int getNumPara(){return numPara;}[COLOR=Magenta];[/COLOR][/code]I believe it's telling you it would prefer that the [FONT=Courier New]this[/FONT] pointer be [FONT=Courier New]const[/FONT]. (And function definitions don't end with a semicolon.)[code] inline string getHandle() [COLOR=Blue]const[/COLOR] { return cHandle; } inline int …

Member Avatar for alone2005
0
140
Member Avatar for fEaRdArEaPeR

[QUOTE=fEaRdArEaPeR]i want a program which can compare both the lists and tell me if anyone has gained or lost castles and land.[/QUOTE]Does your OS already come with one? There's [FONT=Fixedsys]FC[/FONT] on my Windows box. [quote][FONT=Fixedsys]FC Compares two files or sets of files, and displays the differences between them.[/FONT][/quote]

Member Avatar for Narue
0
231
Member Avatar for Fanion

[QUOTE=Fanion]I have just started doing a little C programming and, looking here and there, I have noticed a lot of people prefers to use <iostream.h> library (and related commands "cout" and "cin") instead of using <stdio.h> library (and related commands "printf" and "scanf")[/QUOTE][FONT=Courier New]cin[/FONT] and [FONT=Courier New]cout[/FONT] are C++, not …

Member Avatar for Narue
0
91
Member Avatar for alone2005

[code]#include <iostream> #include <string> #include <sstream> int main() { std::string token, text("Here:is:some:text"); std::istringstream iss(text); while ( getline(iss, token, ':') ) { std::cout << token << std::endl; } return 0; } /* my output Here is some text */[/code]

Member Avatar for alone2005
0
10K
Member Avatar for desidude

[code] while (fin >> val) { fin >> val; if (val < min) val = min; else val = max; }[/code]Change [FONT=Courier New]min[/FONT] and/or [FONT=Courier New]max[/FONT], not [FONT=Courier New]val[/FONT].[code] while ( fin >> val ) { if ( val < min ) { min = val; } if ( val …

Member Avatar for desidude
0
225
Member Avatar for Asif_NSU
Member Avatar for Asif_NSU
0
924
Member Avatar for djbsabkcb

[QUOTE=djbsabkcb]Below is my new code for this julian day program. I have fixed some of the errors I mentioned earlier. However, the day is still one short for the julian day and my conditional if statement seems to be the problem. I have tried a couple of ways to fix …

Member Avatar for zyruz
0
639
Member Avatar for logic321
Member Avatar for Narue
0
393
Member Avatar for Kob0724

[QUOTE=Kob0724]What I was really looking for was some kind of an explanation.[/QUOTE]This is an empty loop body.[code]while(condition)[COLOR=Red];[/COLOR][/code]

Member Avatar for Narue
0
179
Member Avatar for dark7angelx07

Surely you can take a stab at the "write a prototype" part. You have been dumping homework and not showing an attempt to solve them yourself. Please read the [url=http://www.daniweb.com/techtalkforums/announcement8-2.html]Announcement[/url].

Member Avatar for Narue
1
649
Member Avatar for kashif07

[QUOTE=kashif07]plz read the the my problem and send the best solution of my problem as soon as possible.[/QUOTE]You're kidding, right? Please read the [url=http://www.daniweb.com/techtalkforums/announcement8-2.html]Announcement[/url].[quote]This forum is meant for discussing programming languages in addition to exchanging code and algorithms. However, it has become a problem where too many students are posting …

Member Avatar for Dave Sinkula
0
373
Member Avatar for Giant

[code]testpp.cpp: Error E2209 testpp.cpp 3: Unable to open include file 'stdafx.h' Error E2268 testpp.cpp 11: Call to undefined function 'malloc' in function vGetPixelValueIntoArray(float *) Warning W8060 testpp.cpp 11: Possibly incorrect assignment in function vGetPixelValueIntoArray(float *) Error E2268 testpp.cpp 12: Call to undefined function 'fprintf' in function vGetPixelValueIntoArray(float *) Error E2451 …

Member Avatar for Dave Sinkula
0
593
Member Avatar for shahid

Follow the instructions as best you can to begin developing some code. When you get stuck, post the code you have (within code tags) and any error messages you get; then you can ask a more specific question. And "I don't even know where to begin" is not the kind …

Member Avatar for Dave Sinkula
0
163
Member Avatar for mr. President

[QUOTE=mr. President]I am having problems with this program and nned help understanding this.[/QUOTE]Could you describe your problem (or is it just the syntax errors)? Perhaps you could also post a small sample input file so we don't have to reinvent your wheel?

Member Avatar for mr. President
0
136
Member Avatar for gebbit
Member Avatar for Dave Sinkula
0
188
Member Avatar for bandm

>Am I doing something wrong? Nope. Your program opens a command shell, executes sucessfully, and having nothing further to do the command shell is closed. Happens in the blink of an eye. [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043803465&id=1043284385[/url]

Member Avatar for bandm
0
199
Member Avatar for JoBe

Here's an ever so minor nitpick. [QUOTE=Rashakil Fol][code]bool are_mirrored(const string &name, const string &name2) { if ([COLOR=Red]name.size()[/COLOR] != name2.size()) { return false; } string::size_type i = [COLOR=Red]name.size()[/COLOR]; string::size_type j = 0; while (i) { if (name[--i] != name2[j++]) { return false; } } return true; }[/code][/QUOTE]Now it's nothing much when …

Member Avatar for Dave Sinkula
0
248
Member Avatar for jazzyjoe
Member Avatar for murschech
0
147
Member Avatar for cymerman

[code]////////////Calulates and prints the check///////////////////// void printCheck(menuItemType printorder[]) { //double tax = .05; // double amountDue=0; [COLOR=Blue]int x[/COLOR]=0; cout <<"-------------------------------------------------"<<endl; cout<<" Welcome to Johnny's Restaurant"<<endl; cout <<"-------------------------------------------------"<<endl; for([COLOR=Red]int x[/COLOR]=0;x<2;x++) { cout<<printorder[x].menuItem<<setw(8)<<printorder[x].menuPrice<<endl; //cout<<menuList[x].menuItem<<setw(8)<<menuList[x].menuPrice<<endl; //cout<<menuList[x].menuItem<<setw(8)<<menuList[x].menuPrice<<endl; } //cout<<"Tax................$"<<tax<<endl; //cout<<"Amount Due.........$"<<amtDue<<endl; }[/code]

Member Avatar for cymerman
0
254
Member Avatar for cpp noob

[QUOTE=cpp noob]is their any way i can make a char statement conatining spaces too.[/QUOTE]What question are you trying to ask? The best I can manage is, "How can a read a line of text containing whitespace from the user?" If so, my next question would be, [url=http://www.daniweb.com/code/snippet278.html]C[/url] or C++?

Member Avatar for cpp noob
0
305
Member Avatar for Kimmy

<< moving from [url=http://www.daniweb.com/techtalkforums/forumdisplay.php?s=&daysprune=2&f=8] C and C++[/url] to [url=http://www.daniweb.com/techtalkforums/forumdisplay.php?s=&daysprune=2&f=122]Troubleshooting Dead Machines[/url] >>

Member Avatar for djrivera1
0
134
Member Avatar for bandm

I don't know anything about VS.NET, but I do know that MSVC6 was not very standards compliant and it had bugs -- so I wouldn't recommend MSVC6.

Member Avatar for Narue
0
207
Member Avatar for M Tritt

This may be an issue.[code]for ([COLOR=Red]int col[/COLOR]; col < b.size; col++) {[/code]Initialize [FONT=Courier New]col[/FONT]. As far as the other error, let me try to find the rest of your code. (And functions don't end in a semicolon.) [edit]The advice [url=http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.9]here[/url] is to have it the other way around -- to …

Member Avatar for M Tritt
0
131
Member Avatar for shre86

>Anyone has any idea how to convert from any data type to strings C: [FONT=Courier New]sprintf[/FONT] C++: [FONT=Courier New]ostringstream[/FONT] >as only strings can be sent in that Not entirely true, but you may want to use the conversion to string method anyway, because... >i need to send structures Sending structures …

Member Avatar for Dave Sinkula
0
135
Member Avatar for murschech

>Is there a way to paste it? That's my usual preferred way. I'll flip over to my editor, [FONT=Fixedsys]Ctrl-A[/FONT] to "Select All" of the file, [FONT=Fixedsys]Ctrl-C[/FONT] to copy; flip back to the message editor and [FONT=Fixedsys]Ctrl-V[/FONT] paste it right smack in the middle of [co[u][/u]de][/co[u][/u]de]. YMMV.

Member Avatar for Dave Sinkula
0
218
Member Avatar for JoBe

Is [FONT=Courier New]vkv.h[/FONT] saved in [FONT=Courier New]C:\Program Files\Microsoft Visual Studio\MyProjects\LATestVoorbeeldenBoekVervolg2\[/FONT]? [aside]If you still associate headers with linking and you are not using templates, then I think you have some lingering confusion.[/aside]

Member Avatar for JoBe
0
495
Member Avatar for DotNetUser
Member Avatar for darklordsatan
0
232
Member Avatar for M Tritt

[code][COLOR=Red]GamePiece::[/COLOR]GamePiece& operator=(const GamePiece& right)[/code]should be[code]GamePiece& [COLOR=Blue]GamePiece::[/COLOR]operator=(const GamePiece& right)[/code] If you return a value, you should return a value.[code][COLOR=Red]ostream&[/COLOR] operator<<(ostream& os, const GamePiece& p) { os << p.pName << endl; os << p.pType << endl; [COLOR=Blue]return os;[/COLOR] }[COLOR=Red];[/COLOR][/code]And don't end functions with a semicolon. You can't change a const object. Sorry …

Member Avatar for Dave Sinkula
0
236
Member Avatar for Yoshidex

Data type is usually the most important thing to include -- how is [FONT=Courier New]fout[/FONT] declared? If it is an [FONT=Courier New]ofstream[/FONT], you are using the default mode, which I believe means to truncate an existing file. I think you would need to use an [FONT=Courier New]fstream[/FONT] opened for read/write …

Member Avatar for Yoshidex
0
343
Member Avatar for M Tritt

Please do not ask for help or offer assistance via email. Post questions to the forum and post replies to the forum. This helps others who may find this question in the future, and it also allows for constructive criticism of proposed solutions.

Member Avatar for M Tritt
0
1K

The End.