15,300 Posted Topics
Re: stop using scanf() because it may corrupt the input buffer and leave keys in the keyboard buffer. use fgets() instead [code] float num; char buf[16]; printf("blabla"); // get input from user fgets(buf,sizeof(buf),stdin); // convert to float num = atof(buf); [/code] | |
Re: >>typedef basic_string<unsigned char> ustring; above is unnecessary. just use c++ string class. so you might as well delete that line. >>inData>>Name>>iNum[i]; If there are spaces in the name then above will not work because extraction operator >> stops at the first space. In that case you need to use getline() … | |
Re: your program should read the first number -- 5 in your example -- then have a loop that reads that many more numbers. If the file contains more than one line like that, the program should have an outer loop that performs those actions for each line in the file. | |
Re: you could make foo1 a base class [code] class foo1() { // blabla }; class foo : private foo1 { // blabla }; [/code] | |
Re: please edit your post to use code tags -- all that unformatted code hurts my eyes. | |
Re: something like this: note, we are not going to write the program for you. [code] open the file do this until end-of-file is reached use extraction operator >> to read a word check each character and remove any non-alphabetic characters (hint: isalpha() macro will help you do make that check) … | |
Re: 1. is the input file (data.txt) a binary file or a text file? If you can read it with Notepad.exe then its a text file, otherwise if the data is unreadable then its a binary file. Only binary files are read with iostream.read() function, text files use getline() or the … | |
Re: I use IE6 at work and IE7 at home. Years ago I used Netscape, but the make a new version that I really hated and stopped using it. | |
Re: certifications --- hummmm. I have a HS graduation certificate, a marriage license, associates of arts degree, several medals from viet nam, a military retirement certificate, a social security card, a i will be getting an old-age social security retirement certificate in a couple years. I think that's enough certifications for … | |
Re: We are all students -- some are just more experienced than others. I have been a student of computer programming for the last 30 years or so and feel like I am still learning this stuff. So just because you get a degree does not mean you will not stop … | |
Re: use strchr() to find the comma then replace it [code] char str[] = "Hello,World"; // find the comma char *ptr = strchr(str,',') // replace it if found if(ptr != NULL) *ptr = ';'; [/code] Now, put the above in a loop to find and replace all the commas in the … | |
Re: [QUOTE=jan1024188;260765]why that doesnt work? #include <stdio.h> int main () { char lala ; printf ("Enter string:"); scanf("%s", &lala); printf ("%s\n", lala ); return 0; }[/QUOTE] 1. please use code tags as shown in ~S.O.S~'s example. 2. you did not declare variable lala correctly -- study ~S.O.S~'s example and pay close … | |
Re: I think what you want to read is [URL="http://www.daniweb.com/techtalkforums/thread13488-2.html"]this[/URL] thread. | |
Re: badly formatted condional statement [code] if( (strcmp(ptr,"int")[color=red]== 0[/color]) || (strcmp(ptr,"float") [color=red]== 0[/color]) ) [/code] ![]() | |
Re: Huh? I think you need a better explaination. Most programs written today can process that size file. But if you use some ancient compiler such as Turbo C then you can probably forget about it. | |
Re: [URL="http://www.turboexplorer.com/"]They're back!:[/URL] :eek: [IMG]http://www.turboexplorer.com/css/CPPboxshot.jpg[/IMG] | |
Re: I am using IE7 and really like it -- I see no reason now to use FireFox. The only reason I used it before was because of the tabs, and now Microsoft as [b]borrowed[/b] that idea. I don't see any advantage of running FireFox over IE7. | |
Re: yes -- but you have to write the program youself. We are here to help YOU write programs, not for us the do your work. What does a timekeeper like shape look like ??? | |
Re: normally yes, write a thread-safe wrapper for the functions in the library. How to do that depends on the compiler and operating system you are using. | |
Re: [code] for (x=0; x <strlen(pword); x++) { file2.open(fname, ios::in); file2.getline(stuff, 3); file2.close(); cout << (char)okay; } [/code] What the H is the above supposed to do? What it [b]IS[/b] doing is opening a file, reading the first line, the closing the file -- all that possibly hundreds of times (depending … | |
Re: looks like a missing library. you probably need to add libodbccp32.a to library list. | |
Re: I don't know the answer, but I hope you realize that in many countries (like USA) recording telephone conversions is illegal unless (1) you have the permission of the person being recorded, or (2) you have a court order, or (3) you happen to be the President of the US … | |
Re: you can not use the name of functions as the name of a variables. Function names must be different from variable names. Example: residential_rate is used both as a function name and a variable name, and since the variable name is in _tmain() the compiler is treating that symble as … | |
Re: I don't really know a thing about that file, but that sort of error message usually means the file is not in one of the directories in the PATH environment variable. search the hard drive to see if that file was installed. If not, then install it. | |
Re: >> i didn't get any reply I don't recall seeing another post -- did I miss it? 1. is that a C or a C++ program? You include both stdio.h and iostream, yet you use C file i/o functions. Make up your mind which kind of program you want and … | |
Re: why is sum a linked list and not a simple integer? [code] int sum(nd **head){ nd *pl [color=red]int sum1 = 0;[/color] p=*head; while(p!=NULL) { sum1 += p->x; p=p->next; } return sum1; } [/code] | |
Re: you will have to 1) learn SQL database language -- SELECT, INSERT and UPDATE are three most commonly used SQL functions. 2) learn how to use ODBC to access the database from C, C++ or most any other computer language. [URL="http://www.easysoft.com/developer/languages/c/odbc_tutorial.html"]Here[/URL] is a short tutorial to get you started. And … | |
Re: anyone know where to buy it? I checked M$ site but they only linked to hardware manufacturers, such as Dell, HP, and IBM. All I want is the os, I already have the hardware. | |
Re: >>Okay, Iv'e finished learning C++. :cheesy: :cheesy: :cheesy: :cheesy: :cheesy: :cheesy: you will NEVER be finished learning c++. That is a life-long task. If you want to learn MS-Windows GUI programming [URL="http://www.winprog.org/tutorial/"]here[/URL] is a good introduction. Its c instead of c++ but then so is all the win32 api functions … | |
Re: worst case: run it on an old 80x88 computer that has 0.4 MG CPU chip, if you can find it. best case: run it on a [URL="http://www.cray.com/"]cray computer[/URL] average: average the two above seriously: the timings will all depends on the os and CPU you run it on. And you … | |
Re: [URL="http://en.wikipedia.org/wiki/Serendipity"][b]Serendipity[/b][/URL] because I find something new almost every day, especially in these programming web sites:) | |
Re: does the code compile with no errors? It does not with my compiler. You have to fix all the errors before attempting to run the program. >> void main() main never ever returns [b]void[/b]. The correct way to dealre that function is like this -- any other way is wrong.: … ![]() | |
Re: I work with two women -- one is my supervisor and the other does the same thing as I do. Our company has several other women too, one has a Ph.D. of some sort. | |
Re: congratulations on passing the exam. May the money start flowing in from all around you :) :) :) | |
Re: your best bet for answers is to find a users-group that specializes in that language. Check out their web site to see if they have one posted. | |
Re: you mean you want to create a web site something like [URL="http://www.programmersparadise.com/PPI_US/Default.aspx?source=webgoog"]this[/URL] ? | |
Re: [QUOTE=shermaine;258907]Thanks! But it doesn't seem to get any output? Please advise. Anything i should input to show output like f(5) = 5? Thanks.[/QUOTE] what output are you expecting? your program does not contain any code to print anything on the screen. For C programs use printf() function, c++ programs use … | |
Re: >> how to pass a string as an argument to a sub fuction The same as you would any other data type [code] void foo( const char* some_string) { } int main() { foo("Hello World"); return 0; } [/code] >>what is the maximum limit of subscripts that the character array … | |
Re: the loop is formatted wrong. Crevat: atof() does not detect errors in the string, but it doesn't really matter if you know the strings are all formatted ok. [code] while( in.getline(ch, 256, '\n')) { numbers.push_back(atof(ch)); } [/code] better yet, use a std::string instead of a char array [code] std::string line; … | |
Re: there are several [URL="http://www.fredosaurus.com/notes-cpp/algorithms/searching/binarysearch.html"]examples and tutorials[/URL]. I suggest you use a structure to hold the data for one account then put the structures in an array. That helps keep all the data together when sorting and searching. The actual algorithm you are looking for is almost the same as shown … | |
Re: why not just index into the string? You don't need a vector just to get a character from the string object. [code] std::string s = "Hello World"; for(size_t i = 0; i < s.length(); i++) { char c = s[i]; cout << c << "\n"; } [/code] If you really … | |
Re: [code] #include <stdio.h> int bitcount(unsigned x) main() { int b; for (B=0; x!=0; x >>=1) [color=red]<<< Where are these variables declared?[/color] if (x &01) btt [color=red]<<< what the he!! is this??? [/color] return b; } [/code] | |
Re: what do you want to know about fractions? (see any 2nd grade math book -- if you are in college then shame on you!:mrgreen: ) | |
Re: Shermaine: you need to edit your post and reformat that code to make it readable -- I'm not going to read that crap! | |
Re: I don't know the first thing about it, but from what little I found in [URL="http://homepage.usask.ca/~ijm451/finite/fe_resources/fe_resources.html"]google links[/URL] it looks like it is pretty involved. Scroll down the page and you will find some free source code. I don't know how good it is so use it at your own risk. | |
Re: >>may i know how should i write to prompt user to enter the four weights from the keyboard. just create a loop for this [code] int i; float weights[4] = {0}; char buf[80]; for(i = 0; i < 4; ++i) { printf("Enter weight #%d", i+1); fgets(buf,sizeof(buf),stdin); weights[i] = atof(buf); } … | |
Re: main() always returns an int, never void. There are still a lot of bad examples on the net that show void main() but they are obsolete and wrong. [code] int main() { // your code here return 0; } [/code] | |
Re: c++ or c programs (or programs written in any other language for that matter) are unreliable at best because the os may overwrite the sectors on the next write. Even Norton Utilities is not all that reliable. MS-Windows added the trash can for exactly that purpose, when a file is … | |
Re: why are those double and int arrays 2-dimensional??? Arrays must have a name. There are a couple ways you can to it. Leave the array size unspecified and pass the size as another parameter, as in your original attemp. [code] void PrintArray(double array[], int array_size); void BubbleSort(double array[], int array_size); … | |
Re: >>can u guys help do the totalunitcost for each specific customer, i tried everything could get it done If totalunitcost is the simple sum of rSale[i].UniCost, then just sum it up while reading the data file. [code] fread(rSale[i].UniCost,3,7,fps); totalunitcost += atof(rSale[i].UniCost); // assume this is a float [/code] |
The End.