15,300 Posted Topics
Re: line 12: you are attempting to use [b]string[/b] as both c++ object type and a variable name. You have to rename it to something else line 13: why are you using character arrays here? You can just use std::string class [code] string fileword, fileline; [/code] The loop that starts on … | |
Re: It is not necessary to state [icode]std::cout[/icode] on every line -- most programmers code a using statement at the top [code] #include <iostream> using std::cout; int main() { cout << "Hello there.\n"; cout << "Here is 5: " << 5 << "\n" cout << "The manipulator std::endl"; cout << "writes … | |
Re: >>I have an assignment due tomorrow So why did you wait so long before starting it? You can't be a procrastinator in computer programming because its probably the most time consuming course you will ever take in college. | |
Re: The problem is the way you formed that while loop -- it reads the last entry in the file twice. Here is the correct way to code it. Notice that eof() is not necessary. [code] while(empFile >> thisSalary) { emp[i].setSalary(thisSalary); //assigns to the array cout << emp[i].getSalary() << endl; //for … | |
Re: >>Could anyone tell me about what are the test cases i should do? Test everything. | |
Re: depends -- what compiler are you using. If Microsoft they are installed with the compiler. VC++ 2005 Express you will need to download the Windows Platform SDK to get them, which is a huge download. | |
Re: how about this: [icode] cout << setw(40) << left << "John" << setw(40) << "Smith" << "\n";[/icode] | |
Re: It would be nice to know what this program is intended to do. It is trying to convert pounds and shillings to something, but I don't know what. | |
Re: If you use the vector class you don't have to know how many words there ahead of time. Just read the file once and add each word to the vector -- it will expand as necessary to contains all the strings [code] #include <vector> #include <string> #include <fstream> #include <iostream> … | |
Re: 1)[icode] 3 2 8 7 1 5 6 0 0 0 0 0 0 0 0[/icode] The reason for all those 0s at the end is that the compiler will initialize any unspecified array elements with 0 as long as there is at least one initializer Example: [icode]int array[15] = … | |
Re: Either you are using a crappy compiler or you did not post the current code: [b]ticTacToe.cpp[/b] >>TicTacToe::ticTacToe() Spelled wrong. [b]TicTackToe.h[/b] missing the constructors referenced in the *.cpp implementation file. I'm giving up now. | |
Re: What makes you believe that information is in the registry ? | |
Re: The easiest was is not to put the duplicates in the array in the first place. When you read a city name from the file check to see if the name is already in the array. If not, then add it. | |
Re: >>while(1); That's an infinite loop >>void main() Not a good thing to do. [URL="http://www.gidnetwork.com/b-66.html"]Here's why[/URL]. The function just above main is missiong a closing } | |
Re: Welcome to DaniWeb. Sounds like you are really enjoying yourself in Cambodia :) | |
Re: [QUOTE=caperjack;598794]don't get mad, get even ,throw out the computer ! .[/QUOTE] Don't laugh -- I did that once. I got to angry that I tossed the computer, monitor and all books out the back door and smashed it all on the concrete patio! I felt great after doing that :) | |
Re: For MFC stuff you should get familiar with [url]www.codeproject.com[/url] because they have hundreds of free MFC programs you can use as examples. A search for treeview got over 100 hits. Also there are [URL="http://www.google.com/search?hl=en&q=mfc+treeview+tutorial&btnG=Search"]several tutorials[/URL] on the net | |
Re: look at the function parameters and then look at what you are trying to pass. There apparently are some difference. I'd say you're trying to pass a pointer where its not supposed to be a pointer, or vice versa. | |
Re: I think menu Project --> Add To Project, then select the library you want to add. Could be wrong about that though. | |
Re: [QUOTE=jasimp;597367]Welcome! Stephen King is the greatest author of the 20th century. I am a slight addict to his works. Besides The Dark Tower, IT is the greatest thing he has written.[/QUOTE] [URL="http://users.erols.com/mwhite28/top100s.htm#Novels"]Others will disagree [/URL]with that. | |
Re: [QUOTE=briansmall;536787]What is ... the most important thing you pursue?[/QUOTE] Getting my afternoon nap :) | |
Re: >>int position should be [b]size_t[/b] position because negative positions are not valid and size_t will allow for files twice the size (about) as int. >> char word[] use std::string here to avoid the many problems with character arrays. use a vector instead of that huge array because vector will expand … | |
Re: its not necessary to use strtok() to get the filename part. Just call [URL="http://www.cplusplus.com/reference/clibrary/cstring/strrchr.html"]strrchr()[/URL]. This is a safer way to do it because strtok() requires non-literal strings and the function below doesn't. [code] char* get_filename(char *path) { char* ptr = strrchr(path,'/'); if( ptr != NULL) ptr++; return ptr; } [/code] … | |
Re: >>Could someone please tell me how can i open a txt file with a press of a button (MFC)? In the OnClick() event handler for the button. >>Is there any way i can transform a cpp file to a txt file No conversion needed -- the *.cpp file is already … | |
Re: 1) when using vectors you can access individual elelements just as you would do with a simple int array [icode]B = LiDARGrid.ConcentricScans.[scancounter].getColumn(concentriccol);[/icode] Otherwise, this works. Your problem is probably something other than push_back [code] #include <vector> #include <iostream> using namespace std; int main() { vector<double> Saved; for(int i = 0; … | |
Re: Scooby, Road Runner, the Jetsons, Underdog, were and still are my favorites. Yes, even at my ags, I still watch cartoons occasionally :) | |
Re: >>i close the file and reopen it to get back to the start of the file (not the best way i know) Just call [b]rewind()[/b] function or [b]fseek()[/b] >>if(strncmp(line,"v",1)== 0) using strncmp() like that is too time consuming. Since the letter you want is at the beginning of the line … | |
Re: [QUOTE=thekashyap;598593]also I didn't know C++ allowed type names to start with numbers.[/QUOTE] It doesn't :) | |
Re: [QUOTE=majestic0110;595620]That is odd, I had no experience of this and have been on and off most of the day lol[/QUOTE] That's because you live in the wrong time zone. The term "this morning" doesn't really mean much because for you in UK "this morning" is "last night" where I live. … ![]() | |
Re: delete main() out of stack.cpp and everything links ok for me. Using VC++ 2008 Express. Do you have stack.cpp part of our compiler's project ? | |
Re: That code won't work because it is an error to cast an int pointer to a float pointer. The two objects have to be the same size, and int is not the same size as a float. If you need to pass something with decimal places to a function then … | |
Re: Its probably the way you created the project. [URL="https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3084692&SiteID=1"]This link[/URL] suggests you start with an empty project. You might also read some of [URL="http://search.microsoft.com/results.aspx?mkt=en-US&form=MSHOME&setlang=en-US&q=c1010070&x=3&y=7"]these links[/URL]. | |
Re: just use getlin() to get each line [code] #include <sstream> // <snip> std::string line; int lines = 0; int words = 0; while( getline( inFile, line) ) { lines = lines + 1; // now split line into words stringstream str(line); string word; while( str >> word) { words = … | |
Re: I tried to submit the answers to the questionaire about 5 times and apparently failed each time. So I gave up. | |
Re: Here is an example [code] // create instance and use default constructor sphere obj; // create another instance but specifiy the radius int radius = 20; sphere obj1(radius); // now change the radius radius = 21; obj.setradius(radius); [/code] | |
Re: you can write your program with notepad but you can't compile it because notepad is not a compiler. If your school computers don't have a compiler then ask one of the teachers if they will download it for you. | |
Re: >>compare and index or argv to i. I suspect you misunderstood your assignment. | |
Re: line 27, you have to pass the pointer CF5 by reference, you are only passing it by value. I only show the corrections to a few lines. Function resize_long_pointer() will require several other corrections to accommodate the double star (pointer to a pointer) [code] // line 13: void resize_long_pointer(long *[color=red]*[/color],long … | |
Re: Cool :) I'll have to try that tomorrow. >>none of your links ever work for me, i always get white screen Move to USA where you will be closer :) ![]() | |
Re: >>detailsPtr head; That is an uninitialized pointer. Set it like this and everything should work. [icode]detailsPtr head = NULL;[/icode] | |
Re: [quote=Salem]You are likely to be ignored, or written off as a loser, if you [list] [*]cross-post to too many different newsgroups [/list] [/quote] Yup. | |
Re: >>reply plz plz in two days i have to submit it in 4days That is your problem, not ours. How long have you had that assignment ? What are the requirements ? "A budget for an office" could mean almost anything. | |
| |
Re: Do you mean [URL="ms-help://MS.VSCC.v90/MS.msdnexpress.v90.en/dv_vbalr/html/6e55faae-d32f-4038-9b21-245e25399dba.htm"]this function[/URL] ? Not exactly -- use ifstream declared in <fstream> file and its >> operator or getline() function to read data into a variable. [URL="http://www.cprogramming.com/tutorial/lesson10.html"]Here [/URL]is one of many tutorials you can find on the net | |
Re: All three do the same thing but in different ways -- ODBC is the oldest and best supported method of accessing an SQL database. It is supported by virtually every SQL database and 32-bit c/c++ compiler. The other two originated at Microsoft. [URL="http://en.wikipedia.org/wiki/OLE_DB"]OLEDB[/URL] and [URL="http://en.wikipedia.org/wiki/ADO.NET"]ADO[/URL] | |
Re: since you reposted your code I deleted the post on the c++ board. | |
Re: No tutorial because each compiler does it differently. I don't know how Borland Builder 6 does it -- you should ask someone in the Borland support forums. | |
Re: >>program is running fine from the tc I guess that means Turbo C compiler ? Sounds like the csv file is not where you think it is. Check to see that it is located in the same directory as the *.exe file. If not, then did your program specify the … |
The End.