15,300 Posted Topics
Re: Use fgets() if you want to put spaces in the text. The side affect of fgets() is that it puts '\n' at the end of the string, if it will fit. [icode] printf("Dog's name?:"); fgets(str2, sizeof(str2), stdin); // now remove the '\n' from the string if( str2[strlen(str2)-1] == '\n') str2[strlen(str2)-1] … | |
Re: Your link appears to be broken -- I get an IE error that the page can not be displayed. | |
Re: what is the error??? Please don't make us guess. You don't need a loop just to get the first letter of the string, so you can just delete lines 17, 18 and 29. [icode]cout<<lastName <<", " <<firstName<<" " <<middleName[0] <<endl;[/icode] | |
Re: 1. you don't need that while loop that starts on line 5 so just delete it2. 2. The for loop sould cout from 0 to < size, not <= size-1. If the value of size is 5, then you want it to count 0, 1, 2, 3 and 4. 3. … | |
Re: The structure is declared incorrectly -- wrd needs to be a pointer so that it can be allocated at runtime. [icode] struct word { int count; // counter to use the word's occurrence char* wrd; }*wordptr[50]; [/icode] line 21: >>wordptr[position] = (struct word *) malloc(sizeof(struct word)); You need to do … | |
Re: Those pictures are called avatars, and are available to anyone. Set yours in the CONTROL PANEL link found at the top of each DaniWeb page. Everyone also have titles, but certain members can create their own title (admins, past and current mods, and those who donate their money to DaniWeb, … | |
Re: >> if(foo()) But Hello World should be displayed regardless of the return value of foo(), and the || 1 causes that. So you can't just toss out that or condition. | |
Re: Have you studied [URL="http://winprog.org/tutorial/"]this tutorial[/URL]? | |
Re: You mean how to convert column A to column 1? Yes, that can be easily done. The quickest way would be to take the single-letter column value and subtract 'A'. So if the column name is 'C', then it would be 'C' - 'A' + 1, which is 67 - … | |
Re: line 15 of report.cpp: That line doesn't do what you want it to do. sizeof(any pointer) is always the same. Arrays are always passed to functions by pointer even if you declare it like an array. Since this is a c++ program you should use vector<int> sales, then that function … | |
Re: If you do not have the *.lib that normally comes along with dlls then you can use LoadLibrary() to load the dll into memory, then GetProcAddress() to get a pointer to a function in the dll. See [URL="http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx"]this[/URL] for details. | |
Re: >>Sorry, you are all wrong. You may have as many mains as you want, provided they are all static (except one, of course). Nope. The only way to do that is to put each of the static functions in different *.c files and not in the same *.c file as … | |
Re: On PCs there was a speed difference some 30 years ago, but hardware technology has advanced to where there is no longer a speed difference. [URL="http://stackoverflow.com/questions/417568/float-vs-double-performance"]Here[/URL] is just one of many threads you can find on the subject. It is my impression that FORTRAN may be a better language to … | |
Re: With VC++ 2010 look in <cctype> and you will find that it's in std namespace, just as Narue said it is. _STD_BEGIN is defined as [icode] #define _STD_BEGIN namespace std {[/icode] in yvals.h | |
Re: You may have to do a lot of recoding. [URL="http://gauss.ececs.uc.edu/Users/Franco/ForksThreads/forks.html"]Read this thread[/URL]. | |
Re: while statements are incorrect. [code] while( InBoundData>>type ) { InBoundData>>speed>>source>>destination>> distance>>depart>>reach>>hour>>ticketprice; cout<<type<<" "<<speed<<" "<<setw(9)<<source<<" "<<setw(3) <<destination<<" "<<setw(5)<<distance<<" "<<setw(5)<<depart<<" "<<setw(2) <<reach<<" "<<setw(8)<<hour<<" "<<setw(10)<<ticketprice<<endl; } [/code] | |
Re: line 140: The value of Area is undefined because it has not been initialized to anything. I expect what you meant to say is Area = paint_area / COVERAGE. | |
Re: move all those global variables on line 5 down below line 8 so that they are inside the function. Globals are bad -- avoid them when ever possible. | |
Re: Accessing databases can be quite complicated. There are a lot of tutorials about ODBC, the oldest and most widely used way to do it. [URL="http://www.google.com/search?source=ig&hl=en&rlz=1G1GGLQ_ENUS397&q=odbc+c+tutorials&aq=f&aqi=&aql=&oq="]Here[/URL] are a few tutorials for you to study. There are several other ways to do it, depending on the database and operating system, but ODBC … | |
Re: If you want to convert it yourself then amnt=money[i]*10+1; is incorrect. Should be something like below -- you can not assume the string contains all numeric digits. [icode] while( isdigit(money[i]) ) { amnt = (amt*10) + money[i] - '0'; ++i; } [/icode] Now do something similar for the cents. You … | |
Re: what's that [b]demand[/b] stuff??? You start demanding something of us and you will just get ignored. | |
Re: There are at least three ways to launch a process -- system(), ShellExecute() and CreteProcess(). Which one you want to use depends on how much control you want over the newly created process. google for those functions and you will see how to use them. CreateProcess() is the most complicated, … | |
Re: [QUOTE=determine]new the beginning a meant to say "#include iostream" and "#include cmath"[/QUOTE] No -- the way he has it is correct. The name of standard c++ header files go in angle brackets as shown in the code he posted. | |
Re: Do you mean the functions in time.h or ctime? Read [URL="http://www.google.com/search?source=ig&hl=en&rlz=1G1GGLQ_ENUS397&q=c+time+tutorial&aq=f&aqi=g1&aql=&oq="]these links[/URL] | |
Re: My guess is the problem is in CTokenStream, but could be wrong. The problem could also be somewhere before that function is called, such as buffer overruns. | |
Re: you can not put function calls in class declaration unless they are inside inline code. Move that srand() line to main() [code] int main() { srand(time(0)); } [/code] Depending on the compiler you are using you may have to typecase time() to unsigned int instead of time_t. | |
Re: Too bad that tutorial doesn't have an index to make it easier to find something. It's huge and very tedious to search all of it just to find something. | |
Re: Your program should run ok on 64-bit computers even without recompiling it. The only reason I can think of to recompile that program is to take advantage of the additional memory that 64-bit machines can give it. | |
Re: First check your computer to see if winsock2.h actually exists. If it does, then you probably need to make a change to the list of folders that the compiler uses. You will find that list in Tools or Options menu item. I don't have that compiler installed any more but … | |
Re: [URL="http://www.programmersheaven.com/mb/mfc_coding/189694/189694/how-to-redirect-console-output-into-mfc-text-box/"]Here [/URL]are a couple suggestions that may or may not work for you. | |
Re: What kind of program are you supposed to write? Windows Forms? MFC? wxWindows? win32 api? I assume by now you have been given enough instructions in class to complete this assignment. Or have you been sleeping in class? | |
Re: line 18 in Test.h does not declare an array, but only an uninitialized pointer to an array. Therefore line 30 in Array.cpp will crash because the array has no size. Instead of trying to use an array of std::strings, use a std::vector, e.g. [icode]std::vector<std::string> a;[/icode] Then call vector's push_back() method … | |
Re: Good notion, but it doesn't work. I input "Now is the time for all good men to come to the aid of their country." and all I got back was "untry". I was expecting to get back the first 20 characters of what I had typed, and your function to … | |
Re: Attached is an example that I whipped up for someone else not too long ago that shows how to have both a console and windows gui app in the same *.exe program. First, create a windows gui app, then a console app. Copy all the source files from the gui … | |
Re: There is no such thing as c++ 4.5 | |
Re: Do you mean thread ID or window id? All the windows in the same thread of the same thread ID, but each one has its own Window ID (or HWND handle). | |
Re: There are probably quite a few articles about drag-and-drop. [URL="http://www.codeproject.com/KB/shell/explorerdragdrop.aspx"]Here [/URL]is one you might find interesting, its a little old now but probably still relivant. It might be a lot easier if you used CLR/C++ or C# and .NET framework. I'm assuming Microsoft has made drag-and-drop programs easier to do … | |
Re: Your compiler is correct -- look at the parameters to SetTime() and then look at the number of parameters main() is trying to pass to it. They ain't the same. | |
Re: Unless your instructor required you to use Dev-C++, you should replace it with Code::Blocks because Dev-C++ has not been updated for quite a few years and contains a very old version of gcc compiler. Code::Blocks is also free and current. | |
Re: Read the entire file and extract the column(s) you need. I would use fgets() to read a line, then strtok() to split it into individual columns. | |
Re: The PC will have to write the data to the file system because it can't be done from something connected to a serial port. | |
Re: Start with this: [code] #include <iostream> #include <fstream> using std::cin; using std::cout; using std::iostream; using stdLLifstream; int main() { // your program goes here } [/code] Next you will have to create a list of questions and their four possible answers, save them in a text file or just hard … | |
Re: You have to use operating system specific api functions because c++ itself does not support the mouse. On MS-Windows I think you can also use pdcurses library or win32 api console functions. Don't know about *nix, except use curses library for mouse. | |
Re: I don't think it really matters to the compiler which place you put the paths, or even if you put the same path in both places. Its just a matter of organization for you. I put project-specific paths in Additional Include Directories, and compiler-specific paths in C++ Directories. | |
Re: Please read [URL="http://www.daniweb.com/forums/thread87719.html"]this thread[/URL] | |
Re: The parameters to some functions are incorrect -- you have to pass a pointer to a pointer if you want a function to change the calling function's pointer. Example: [code] struct node* InsertAtEnd(struct node** head, int value) { struct node* newnode = CreteNode(); newnode->data = value; newnode->next = NULL; if( … | |
Re: >>I'm using Visual Studio 2008 and referencing a book called "MFC Programming with Visual C++ 6" Get a newer book because MFC changed a lot between VC++ 6.0 and VC++ 2008. The two are not compatible, although you could make it work if you already know MFC well enough. Since … | |
Re: [QUOTE=jwenting;1138145]There is no "best", nor can there be. Not only don't you supply any criteria to use in defining "best" that can be scientifically measured, you don't know all games out there so can't even apply those criteria to every game in existence in order to see how well it … | |
Re: The loop for the cout statement is backwards [icode]for(i = 9; i >= 0; i--)[/icode] |
The End.