2,384 Posted Topics
Re: [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 … | |
Re: 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); … | |
Re: 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 … | |
Re: [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. | |
Re: [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. … | |
Re: 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.) | |
| |
Re: 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) ] << … | |
Re: 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] … | |
Re: Please expand your question to include a few more details. | |
Re: [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. | |
Re: 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) ) { … | |
Re: 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 = … | |
Re: [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1045691686&id=1043284392[/url] | |
Re: 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 << … | |
Re: This is a forum for help with C or C++ programming. There is an announcement or two at the top of it. | |
Re: Why not a vector of vectors (of vectors...)? Your profiling indicated performance requirement issues? | |
Re: [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]. | |
Re: [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 … | |
Re: [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] | |
Re: [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 … | |
Re: [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] | |
Re: [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 … | |
Re: I think you can do something like this. [code]parser.str("");[/code] | |
Re: [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 … | |
| |
Re: [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] | |
Re: 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]. | |
Re: [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 … | |
Re: [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 … | |
Re: 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 … | |
Re: [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? | |
Re: First, you can't write to [FONT=Courier New]realbuf[/FONT] because it doesn't point anywhere. | |
Re: >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] | |
Re: 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 … | |
Re: [url]http://mathworld.wolfram.com/StandardDeviation.html[/url] See (4). | |
Re: [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] | |
Re: [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++? | |
Re: << 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] >> | |
Re: 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. | |
Re: 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 … | |
Re: >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 … | |
Re: >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. | |
Re: 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] | |
Re: [url]http://en.wikipedia.org/wiki/C_Sharp_programming_language[/url] | |
Re: [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 … | |
Re: 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 … | |
Re: 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. |
The End.