15,300 Posted Topics
Re: never never include *.cpp files inside othere *.cpp files. The *.cpp files should be compiled separately and both linked together. The header.h file should be included in both *.cpp files [code] // header.cpp // // system includes #include <iostream> // local includes #include "header.h" // header implmentation code // // … | |
Re: Assuming you have a 32-bit version of the compiler, google for ODBC and you will get lots of information. ODBC is the most common way to access any database. There are several free c++ classes on MySql web site and [url]www.codeproject.com[/url]. You can access ODBC from either C or C++, … | |
Re: there is no guarentee that a short will occupy 2 bytes of memory. The only thing we can be sure of is that char <= short <= int <= long. Notice that on some os all could be the same size. On operating systems where short is 2 bytes and … | |
Re: I must be near-blind or something because I don't see any of your code where you attempted to solve that problem youself :evil: Don't let that overwhelm you. Take the problem one step at a time and you will be able to solve it. | |
Re: [QUOTE=sam1] can you tell me what i am doing wrong? thank you.[/QUOTE] Can't say until you tell us what problems you are having. compiler errors? yes, what are they. runtime errors? name them too. don't be afraid to elaborate a little bit -- band width is not very expensive :) | |
Re: it should work with text files of any size. Are any lines longer than 1,000 bytes? What is the purpose of checking if one of the lines = "int" ? Is there anything else following "int" on that line? This is a c++ program -- why don't you use std::string … | |
Re: during the window's initialization, use the control's Create function, in which you specify the parent HWND, RECT containing the location and height, and the control's ID, among other things. The instance object of the control must NOT be local to a function, but global in the c++ class or program … | |
Re: brackets are in the wrong place [code] for( i = 0; i < 5; i++) delete theArray[color=red][i][/color]; [/code] | |
Re: [code]void main()[/code] That is the first problem -- it must be [code]int main() [/code] Please identifiy other errors you are getting so that we don't have to compile your code. List some of the errors. | |
Re: first, you need to write main() function [code] #include <stdio.h> int main() { // put your code here } [/code] next declare a character array that will hold the name that you input from the keyboard [code] #include <stdio.h> int main() { char name[80]; // allow up to 79 characters … | |
Re: Starting a new thread with the correct date is not going to help you get anyone to do your homework for you. Nobody is going to symaphize with someone who makes NO effort to do it yourself. | |
Re: [QUOTE=nabil1983] Also what is meant by the terms 'Programming Time' and 'Execution Time' in relation to algorithms.? [/QUOTE] how long time it takes for the algorithm to execute. For example, if testing a sort algorithm, how long does it take the alogithm to sort the data. That is normally measured … | |
Re: [QUOTE=some one]i do not know how to compare the date the customer enter with the local time[/QUOTE] use the struct tm and associated functions that are in time.h. get local time in time_t (an unsigned int) -- time() function returns that. Then convert the time string the user enters into … | |
Re: [QUOTE=desertstorm]How's it going: How do you use fopen() to establish a stream to console I/O (keyboard)? What I needed to do is read in data from the console I/O and then send it elsewhere using fputs. I just don't know what the first argument for fopen("here", r) would be. Oh, … | |
Re: there are lots of them. [code] int main() { char *ptr = malloc(10); return 0; } [/code] The above will produce an error when compiled with c++ compilers. | |
Re: [code] #include <iostream> #include <string> using namespace std; typedef struct data { string dat; } DATA; typedef struct name { string na; string age; // NAME * DATA; [color=red] DATA* nm;[/color] }NAME; [/code] If your intent is to have an object of type DATA inside the structure named NAME, then … | |
Re: short answer -- no, you can't round the internal representation of floats and doubles. That's because many numbers cannot be represented exactly, there are mathametical reasons for that, which is over my head :) but has something to do with powers of 2. However, you can display them rounded using … | |
Re: functions are just small sections of code that perform a specific task. For example, you might have a function called menu() that will display a menu, prompt the user for the menu item and return the menu item number that was selected. Below is an illustration of how to write … | |
Re: It took a little while to work out the algorithm, but below is one way to sort the array indirectly using another integer array. First, initialze an int array with values 0, 1, 2, .... During the sort, swap these numbers instead of members of the original structure array. The … | |
Re: C++ can to everything that C can do plus a lot more. There is nothing in C that can't be done by c++. | |
Re: [code] input (emp_n,emp_w,emp_r,emp_u) int *emp_n,*emp_w; int *emp_r; char *emp_u; [/code] OMG! what book are you reading anyway. We haven't coded like that in over 20 years, since K&R. Your compiler will like you a lot better if you code it like below. [code] input (int *emp_n,int *emp_w,int *emp_r,char *emp_u) [/code] … | |
Re: its probably because what you see in the ascii editor are not spaces at all. Many editors, such as Notepad will display non-printable characters as spaces. What makes you think that file contains spaces? binary files contains all sorts of stuff that are meaningless to ascii edits. If you realy … | |
Re: [quote]>If yes, then when do we need to make a call to setvbuf >with 'buf=NULL' since the 'C' compiler always assigns a buffer automatically(according to u)? Well, if you want to specify buffering but don't want to manage your own buffer, you would pass a null pointer and allow setvbuf … | |
Re: I suppose I should make a post here -- afterall I just joined today. I'm not called "Ancient Dragon" for nothing -- no disrespects intended for dragons :rolleyes: Got this handle from when I played the role playing game Dungeons & Dragons about 10-15 years ago. Few, if any of … | |
Re: > 2) Is there any special reason of- Why most C compilers include most of the header files > implicitly, but in C++ we have to include them explicitly? > I don't think that is the case. You have to include header files in C also. Many (most) system headers … | |
Re: What makes you think it can't be done in C? win32 api has quite a few functions that require callback functions from the application program. I suspect (but don't know) that *nix does too. callback functions like that are often used in serial communications, such as data arriving on COM1 … | |
Re: [QUOTE=nabil1983]I got everything working, a couple of probls with file write. But ill work it out. I just need help on getting the quick sort working here...i got it written and even in my switch statement but for some reason it dont work....ne one know y...?? [/QUOTE] what "doesn't work" … | |
Re: [QUOTE=WolfPack]unichar can be more than 2 bytes? I thought it was always 2 bytes.[/QUOTE] The size of wchar_t is operating system dependent. On MS-Windows wchar_t is defined as unsigned short. *nix computers it is unsigned long. And the UNICODE standards say that they intend to have 64-bit wchr_t. That becomes … | |
Re: The files can be created with fopen() function. [URL=http://www.die.net/doc/linux/man/man3/fopen.3.html]Here[/URL] is a description of the function (not a tutorial). There isn't really much to it: To open for output (destroys the fle if it already exists). [code] FILE* fp = fopen("myfile.txt","w"); [/code] | |
Re: [QUOTE=ilikerps]Of course. I hadn't seen that in the cplusplus.com reference for cstring. In fact, cplusplus.com has apparently no documentation for substr at all.[/QUOTE] substr() is not a function of cstring -- it is a method of c++ std::string class. [code] #include <string> int main() { std::string newstr; std::string str = … | |
Re: [code] int CO[0] = { 0 };[/code] The above is not a valid array -- its an array of 0 elements. that means "CO[0] = 1;" will produce undefined behavior because CO[0] does not exist. | |
Re: if you want a binary file, when you are reading/writing it wrong. Notice how much easer this is than writing/reading in text mode? [code] // write a record fwrite(&myDB[i], 1, sizeof(MyDB[i]), fp); // read a record fread(&myDB[i], 1, sizeof(MyDB[i]), fp); [/code] Does your program even compile correctly? It looks like … | |
Re: In C and C++, arrays are stored in memory by row. That is, all the columns of the first row appear first, then all the columns of the second row, etc. If you have an int array with 2 rows and 5 columns then the location of any given row … | |
Re: I would use getline() to read the entire line, then call string's find() method to locate the spaces. [code] std::string line; while( getline(file,line) ) { while( line.length() > 0) { std::string word; int pos = line.find(' '); if(pos > 0) { word = line.substr(0,pos); line = line.substr(pos+1); } else { … | |
Re: you need to keep up with lastest compiler technologies -- if you don't you will find yourself quickly obsolete. | |
Re: [quote]whenever i compile i keep getting an error saying identifier or declarator expected....for some reason i cant correct it neone know whats wrong???[/quote] Yes -- count the braces in function fileprint(). There are too many closing braces. The easiest way to sort files is to read all the records in … | |
Re: [QUOTE=akki_freak]greetings folks, #include<stdio.h> #define T t void main() { char T = 'T'; printf("\n%c\t%c\n",T,t); } just check what is the output of this program and puhleease tell me reason whyit happens so?? :rolleyes:[/QUOTE] compile and run that program, then you will see for yourself what the output is. Why does … | |
Re: please describe the problem -- what does the program NOT do that it should? Are there any compiler errors? If yes, that are they. Runtime errors? What are they. | |
Re: you are going about this the hard way. This is a c++ program -- stop using C character arrays :mad: You don't have to read the bloody file one character at a time. fstream has operators and functions that will read entire words or numbers into your program for you. … | |
Re: In order to sort, you first need an array of structures. Linked lists can be sorted, but much more difficult than arrays. [code] struct tuple array[NumTuples]; [/code] Now, after filling in all the array elements, you want to pass to function bubble and sort by Year. In the case of … | |
Re: try to fix the errors one at a time. Take the first error for example. It says there is something wrong on line 77, which is nothing more than "};". Nothing wrong there, so the prioblem must be above that line. Look at line 76 -- what's wrong with it? … | |
Re: questions 3 and 13 are identical. Both questions use undefined behavior of data overflow, so results will also be undefined. [quote]Write a "Hello World" program in 'C' without using a semicolon. [/quote] Not possible. [quote]Write a C++ program without using any loop (if, for, while etc) to print numbers from … | |
Re: The error should be pretty obvious -- it cannot find the quoted file. Search your compiler's lib directory for it. If it isn't there, then I don't know how you can get it. If it is there, then all you have to do is tell your compiler where it is. … | |
Re: cout << buffer -- buffer needs to be a null-terminated character array. when you defined buffer you did not initialize it to anything, that means it contains random characters and the buffer may or may not contain a null-terminating 0. So cout just keeps displaying characters searching all memory for … | |
Re: I don't know if this will help, but try [URL=http://www.freedownloadscenter.com/Best/webcam-visual-c.html]here[/URL] | |
Re: [code] node[5]->key = key;[/code] That is wrong syntax. you have to use dot notation, not pointer notation because node[5] is NOT a pointer. [code] node[5].key = key;[/code] [quote]If done this way I don't have to allocate memory to node[5]->key before setting it equal to key right? [/quote] Well, maybe yes … | |
Re: years ago before anyone heard about namespaces programmers had a terrible time avoiding name conflicts in their own code and the libraries they used. That was the main reason (I think) for the introduction of namespaces -- you can have as many objects with the same name as you wish … | |
Re: [code] #include <iostream> #include <fstream> using namespace std; int main() { fstream fin; char fileName[21];[color=red]<< MS-Windows filenames can be 255 characters[/color] char line[500]; char string; [color=red]<<< this is NOT a character array, only ONE character[/color] cout << "Enter the name of file you wish to open: "; cin.getline(fileName, 21); if(!fin) … | |
Re: one way would be to write into autoexec.bat to delete the program, then reboot the computer. |
The End.