15,300 Posted Topics

Member Avatar for Acidburn

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 // // …

Member Avatar for Acidburn
0
139
Member Avatar for rajuwani121

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++, …

Member Avatar for SpS
0
299
Member Avatar for hanuma4

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 …

Member Avatar for Dave Sinkula
0
142
Member Avatar for taha umar

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.

Member Avatar for Ancient Dragon
0
67
Member Avatar for sam1

[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 :)

Member Avatar for dwks
0
212
Member Avatar for Jon182

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 …

Member Avatar for Jon182
0
236
Member Avatar for bops

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 …

Member Avatar for Ancient Dragon
0
547
Member Avatar for JoBe

brackets are in the wrong place [code] for( i = 0; i < 5; i++) delete theArray[color=red][i][/color]; [/code]

Member Avatar for Ancient Dragon
0
785
Member Avatar for tyczj

[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.

Member Avatar for tyczj
0
301
Member Avatar for Dabdob

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 …

Member Avatar for server_crash
0
132
Member Avatar for desiree

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.

Member Avatar for Ancient Dragon
0
154
Member Avatar for nabil1983

[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 …

Member Avatar for nabil1983
0
101
Member Avatar for some one

[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 …

Member Avatar for some one
0
257
Member Avatar for desertstorm

[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, …

Member Avatar for Ancient Dragon
0
310
Member Avatar for Naveena

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.

Member Avatar for SpS
0
123
Member Avatar for Acidburn

[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 …

Member Avatar for Ancient Dragon
0
142
Member Avatar for Valmian

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 …

Member Avatar for dwks
0
348
Member Avatar for new guy n c++

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 …

Member Avatar for Ancient Dragon
0
164
Member Avatar for nabil1983

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 …

Member Avatar for dwks
0
182
Member Avatar for Naveena

C++ can to everything that C can do plus a lot more. There is nothing in C that can't be done by c++.

Member Avatar for dwks
0
146
Member Avatar for ehab_aziz2001

[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] …

Member Avatar for dwks
0
112
Member Avatar for paradox814

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 …

Member Avatar for Ancient Dragon
0
161
Member Avatar for akshayabc

[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 …

Member Avatar for Ancient Dragon
0
324
Member Avatar for samaru

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 …

Member Avatar for Dani
3
6K
Member Avatar for akshayabc

> 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 …

Member Avatar for Narue
0
307
Member Avatar for desertstorm

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 …

Member Avatar for Ancient Dragon
0
116
Member Avatar for nabil1983

[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" …

Member Avatar for nabil1983
0
455
Member Avatar for smaity

[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 …

Member Avatar for Ancient Dragon
0
836
Member Avatar for Amoris692001

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]

Member Avatar for Ancient Dragon
0
137
Member Avatar for ilikerps

[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 = …

Member Avatar for Ancient Dragon
0
135
Member Avatar for heavyc

[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.

Member Avatar for heavyc
0
194
Member Avatar for nabil1983

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 …

Member Avatar for perniciosus
0
188
Member Avatar for sahil_logic

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 …

Member Avatar for Ancient Dragon
0
170
Member Avatar for Acidburn

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 { …

Member Avatar for Ancient Dragon
0
119
Member Avatar for j1979c

you need to keep up with lastest compiler technologies -- if you don't you will find yourself quickly obsolete.

Member Avatar for Ancient Dragon
0
126
Member Avatar for nabil1983

[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 …

Member Avatar for Ancient Dragon
0
235
Member Avatar for akki_freak

[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 …

Member Avatar for Ancient Dragon
0
123
Member Avatar for Platanum

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.

Member Avatar for Ancient Dragon
0
166
Member Avatar for Acidburn

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. …

Member Avatar for Acidburn
0
143
Member Avatar for nabil1983

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 …

Member Avatar for Ancient Dragon
0
142
Member Avatar for some one

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? …

Member Avatar for some one
0
176
Member Avatar for akki_freak

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 …

Member Avatar for Rashakil Fol
0
354
Member Avatar for tristan17

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. …

Member Avatar for Ancient Dragon
0
78
Member Avatar for kdw3

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 …

Member Avatar for Ancient Dragon
0
297
Member Avatar for johnray31

I don't know if this will help, but try [URL=http://www.freedownloadscenter.com/Best/webcam-visual-c.html]here[/URL]

Member Avatar for Ancient Dragon
0
55
Member Avatar for desertstorm

[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 …

Member Avatar for Ancient Dragon
0
756
Member Avatar for kahaj

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 …

Member Avatar for SpS
0
897
Member Avatar for slobo7x

[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) …

Member Avatar for perniciosus
0
464
Member Avatar for Analogsleeper
Member Avatar for vicky_dev

one way would be to write into autoexec.bat to delete the program, then reboot the computer.

Member Avatar for WolfPack
0
221

The End.