134 Posted Topics

Member Avatar for halluc1nati0n

I believe that <string.h> is the old C string header and is now called <cstring> in C++. This is completely different from the C++ strings library. In GCC (g++) you don't need to declare <string> and it will still compile. I guess that it must add it automatically for you, …

Member Avatar for Nick Evan
0
259
Member Avatar for ihatestarch

Vectors can be a lot more convenient to work with than arrays because they're a lot more flexible. For example, you can resize them as you need whereas with an array you'd be giving it a default size when you construct it. If you want to get really good at …

Member Avatar for ihatestarch
0
142
Member Avatar for Sorb3t3ro

You don't "open" c++ in the command line. You edit your programs in a text editor like WordPad/Notepad or in an IDE (much better choice due to syntax highlighting and automatic indentation). Try this IDE if you're just starting out: [URL="http://www.codeblocks.org/"]codeblocks[/URL] Just remember that you'll need to have not just …

Member Avatar for zobadof
0
3K
Member Avatar for greenerworld007

[QUOTE=greenerworld007;1046006]Hi, I hav heard that it isn't that simple to write a program in linux using c. Lots of commands n stuff.Please simplify what actually I've got to do to run turbo c++ in my linux laptop as I am a beginner.[/QUOTE] It's no harder to write C/C++ code in …

Member Avatar for necrolin
0
184
Member Avatar for calypso&noname

You have one of a few choices: 1. Convert your function from returning an int to returning a string 2. Convert MyName to an integer.... maybe something like MyID 3. Convert your function to return a void* and then cast it to a string... Of these choices, option 1 is …

Member Avatar for calypso&noname
0
146
Member Avatar for pavan146

[QUOTE=crazyboy;1036570]using len = array.length( ); functionnn[/QUOTE] Correct me if I'm wrong, but length() works for strings not integer arrays. If it does work then please demonstrate how, because I got a syntax error trying it. Here's some code that I know works. It shows 2 ways of getting the length. …

Member Avatar for Skeen
0
200
Member Avatar for khess

"Much to my disappointment, though, my built-in Broadcom wireless network adapter wasn't supported by default." What you're saying is that you had to install the driver. OK... big deal? What I like about Linux is that you can install the Broadcom drivers from the repository. No CDs required. Have you …

Member Avatar for jaanu123
1
810
Member Avatar for arindamhacking

Do have have access to an admin account? As in any admin account? If so you can reset the password without knowing the old one via net user command. net user administrator *

Member Avatar for crunchie
0
204
Member Avatar for samsons17

Actually you declared total as in integer and you're using it to store the total price. So, it's not printing any decimals because integers don't have any decimal points in them.

Member Avatar for necrolin
0
194
Member Avatar for necrolin

My C++ course hasn't covered a topic yet, but I'm expected to solve a few problems with this material. I've got some working code I just don't fully understand it. Can someone help me, please? [CODE] void f(int** a) //What is this ** business? (1) { cout << **a; //prints …

Member Avatar for dkalita
0
90
Member Avatar for dinamit875

If I understand you correctly then you want to remove the spaces in a string in two passes. In one pass you remove the spaces from the left half of the string and then in the second pass you remove the spaces from the right side of the string. The …

Member Avatar for dinamit875
0
129
Member Avatar for PoRco1x

Who says you can't because my C++ book says you can and my test program works fine too. [CODE] #include <iostream> #include <cstdlib> using namespace std; class MyObject { string data; public: MyObject(string a) : data(a) {} void print() const { cout << data; }; }; int main() { MyObject …

Member Avatar for necrolin
0
144
Member Avatar for neilsam

For one, i & j aren't declared, unless they are global variables.... but my C++ teacher would kill you for doing that. Take a look yourself: [code] for (i=0;i<3;++i) { for(j=0;j<3;++j) [/code] Should be: for (int i = 0 .....) Also, where is c[][] coming from? It just appears in …

Member Avatar for neilsam
0
114
Member Avatar for #www#

[code] #include <sstream> stringstream toString; int num = 55; //Your integer string stringNum; //Your output toString << num; stringNum = toString->str(); toString->str(""); //Clear toString so you can use it again [/code] This code converts an integer into a string. Hope it helps. Here's some more reading on stringstream if you're …

Member Avatar for #www#
0
159
Member Avatar for SCoder1

[code] cin >> numEntered; //Ask for a number //This part is fine, you get a number from the user numEntered = number[i]; //oops, it's backwards //should be number[i] = numEntered instead [/code] Currently your code says: numEntered is some user input numEntered is some uninitialized data... when you want to …

Member Avatar for SCoder1
0
86
Member Avatar for necrolin

If I have 2 classes a) class Business b) class Customer I want the Business class to be able to store a dynamic list of it's customers. So I thought the easiest way to do this would be to use a vector. [code] class Business { vector<Customer> customers; public: Business(); …

Member Avatar for necrolin
0
203
Member Avatar for 17ashis

According to Bruce Eckel the performance difference between C++ and C is usually less than +/-10%. He also noted that a well designed C++ program can be "more efficient than the C counterpart".... aka it can be faster. In any case we can call them relatively equal... depending on the …

Member Avatar for necrolin
0
112
Member Avatar for snowland

I'm lazy so I'll copy and paste from "Beginning Visual C++ 2005" (I have the pdf) When you create a new project workspace, Visual C++ 2005 automatically creates configurations for pro- ducing two versions of your application. One version, called the Debug version, includes information that helps you debug the …

Member Avatar for necrolin
0
86
Member Avatar for th3learner
Member Avatar for ENCHTERP

I can't think of any really simple way to do this. I suppose you could use something like a struct or a union. This way you could store more than one type of variable depending on what you need. I was thinking something like: [code] #include <iostream> using namespace std; …

Member Avatar for ENCHTERP
0
3K
Member Avatar for mauryoung

You said: "Help Me With this please...I'm just learning C++", but you didn't say what you want help with. Where are you stuck? Check for even numbers: variable % 2 == 0 Chick for highest number: just use a variable to store the highest value and use an if statement …

Member Avatar for necrolin
0
116
Member Avatar for naej

iostream allows you to use cout, cin, etc. cstdlib allows you to use system(), exit(), EXIT_SUCCESS, etc. Basically, when you use the #include statement you are adding the ability to use functions/code which were previously written and are located somewhere else in your system, such as in a separate file …

Member Avatar for mrnutty
0
91
Member Avatar for panagos

Google is your friend. Apparently ncurses is available in Mingw as a user contributed library/package called pdcurses. You can get it.... [URL="http://sourceforge.net/projects/mingw/files/User%20Contributed_%20pdcurses/"]http://sourceforge.net/projects/mingw/files/User%20Contributed_%20pdcurses/[/URL] ...by clicking on the above link. Mind you I've never used this package, but it looks like what you're looking for. Hope it helps.

Member Avatar for necrolin
0
263
Member Avatar for jjepoy

The program is using something called binary shifting. For example: 1 << 1 one is binary "001" shifted by one equals binary 010, aka 2. 1 << 2 Binary 001 shifted by two is binary 100, aka 4. So, if we assume that bin == 100 then our first iteration …

Member Avatar for necrolin
0
136
Member Avatar for sweetjhin

[QUOTE=sweetjhin;1010850]I'm not actually looking for a quick answer to my homework. That's why I asked this question because I was hoping that I could find a program that would display the whole calendar. Right now the program I made is just displaying one month and I don't know how to …

Member Avatar for sweetjhin
1
110
Member Avatar for speedy94519

Why don't you write it out in English and then translate it into C? Just write down what you see in each row, 1 row at a time. If it's row 1 or row 2 then the color is blue .. if it's row 3 and the column is 3 …

Member Avatar for necrolin
0
162
Member Avatar for sebassn

The way that you do this exercise is you bust out your handy dandy computer, use your problem solving skills to work it out yourself, try to compile the program, and if you still have problems you ask on a forum. You've just posted 3 of your homework assignments with …

Member Avatar for VernonDozier
-4
106
Member Avatar for sebassn

You do realize that == compares two values whereas = assigns a value. Therefore, it's... t = a; a = b; b = t;

Member Avatar for sebassn
0
113
Member Avatar for chandagondhali

I think you need to be a little more specific. What do you want to accomplish?

Member Avatar for siddhant3s
0
65
Member Avatar for MrMoogles

[CODE] while(infile && cnt < a[NROW][NCOL]){ a[cnt][NCOL] = x; ++cnt; infile >> x; }[/CODE] You're while test is wrong. a[NROW][NCOL] has some random value stored in it because it hasn't been initialized yet, same as a it would in a simple one dimensional array. So, what you're saying is "while …

Member Avatar for necrolin
0
762
Member Avatar for aomran

Like the others already stated this error comes from trying to manipulate a constant. This should make you wonder a few things including: Why am I trying to manipulate a constant? It totally beats the point of making something constant if you're going to decrement it later. If you have …

Member Avatar for aomran
0
2K
Member Avatar for shahanakazi

You'll need 2 for loops (nested). 1 will be for the width and one for the height. [code] for (int column = 1; column < n; column++) { for (int row = 1; row < n; row++){} } [/code] Inside the second for loop (rows) you'll have to implement the …

Member Avatar for Barefootsanders
0
160
Member Avatar for evilguyme

Do you mean like this? [code] string name = "Billy Bob"; cout << "Hello " << name << " you're a wonderful person..." << endl; [/code]

Member Avatar for Nick Evan
0
102
Member Avatar for anuraggupta16

Why is main() inside class N??? By the way your code compiles and works on Solaris, but only if main() is removed from the class. Just copy 'n' past MattyRobot's code into your IDE and see for yourself. ;)

Member Avatar for MattyRobot
0
121
Member Avatar for gerbanzo129

setw(10) << "Agent's Commission"..... Your problem is in your setw(). Width is set to 10 characters but "Agent's Commission" is like 18 characters..... which beats the point of putting setw(10) in there doesn't it? Set the width so that the output actually fits in the width because right now your …

Member Avatar for necrolin
0
93
Member Avatar for suutukil

I suppose you could go for a really easy, but inefficient way of sorting by using 2 arrays. One could be your source array and the other would be your destination. Then just keep on looping though your source array. In loop 1 find the smallest number and copy it …

Member Avatar for suutukil
0
623
Member Avatar for hurbano

The only error in this file is horrible formatting. The program compiles and runs just fine.

Member Avatar for DarthPJB
0
84
Member Avatar for icu222much

I find it frustrating when people ask for help and then don't read the help that they've received only to ask the same question over again... When you code an application and it reaches it's end it closes. Meaning the terminal window will close and you will not see your …

Member Avatar for hao001
0
207
Member Avatar for onaclov2000

There's more than one way to do this. I think that since you don't know how many numbers there are on that line then the easiest way to achieve this would be to use an integer vector and a while loop. While there's data on the line add it to …

Member Avatar for necrolin
0
122
Member Avatar for m_d_ghoda

I've used both for a while and I have to say that Win7 is by far the best OS Microsoft has made to date. It's really really nice. It has a lot of really useful improvements in the UI and Win 7 seems to be a lot snappier on the …

Member Avatar for necrolin
-1
72
Member Avatar for necrolin

What's the difference between (aside from syntax I mean): a) typedef struct MyStruct{....}; b) typedef struct{...}MyStruct; I saw this example in "Thinking in C++", but there's no real explanation as to if they're exactly the same or if there's some real difference in them.

Member Avatar for necrolin
0
96
Member Avatar for athlon32

Correct me if I'm wrong, but wouldn't this be pseudorandom and return the exact same series every time it's run? The way I was taught was to use a seed like this.... #include <ctime> int seed = static_cast<int>(time(0)); srand(seed); int randomNumber = minimum + rand() % (maximum - minimum + …

Member Avatar for MosaicFuneral
0
135
Member Avatar for frog3764

Linux isn't a great platform for gaming. There are few commercial games for Linux so unless you're talking about Flash based games chances are your games won't work. If you want games go Windows.

Member Avatar for necrolin
0
83
Member Avatar for k2k

[QUOTE=sknake;951605]Mac/Darwin is a modified FreeBSD, not linux. I hope that helps you some -- I would start looking at BSD options.[/QUOTE] Actually it's a hybrid of the FreeBSD kernel and the Mach microkernel. You're better off getting Mac packages for a Mac. However, if you really need to install Linux/Unix …

Member Avatar for syahrizal
0
129
Member Avatar for D.JOHN

How big is this array? int marks[student][subject]; Neither student nor subject are not initialized. You initialize them after you create your array.

Member Avatar for D.JOHN
0
157
Member Avatar for Whilliam

Some software tests your hardware and refuses to install if it's minimum requirements aren't met. Minimum requirements are usually the very minimum required to just barely get the program running. If your computer doesn't meet those then don't bother even trying to play. It won't break your computer, but it …

Member Avatar for Xlphos
0
109
Member Avatar for Anpippin

[QUOTE=Anpippin;953954]If I only have Ubuntu on my computer and nothing else does that mean I even have a partition? Because I've never resized the hard drive or partitioned the hard drive or anything like that on that computer.[/QUOTE] Of course you have a partition. You installed Ubuntu into one or …

Member Avatar for caperjack
0
83
Member Avatar for jake43

An integer (int) has no decimals. It will never have any decimals no matter what you do with it. Instead of converting to a double start with a double because you will be able to convert doubles to floats (if you so desire), but not the other way around.

Member Avatar for mrnutty
0
208
Member Avatar for neha arora
Re: c++

[QUOTE=neha arora;950099]i wanna know that if a program consists of 10 lines n if we compile it , it shows increased no of lines compiled why:icon_question:[/QUOTE] Because you're not editing your program you're compiling it. The result of a compilation is an executable program (unless there are errors and you …

Member Avatar for necrolin
0
91
Member Avatar for syedabdulsamad

[QUOTE=syedabdulsamad;946469]Hi Can anyone tell me please How i can make program in C++. Thanks.[/QUOTE] I don't think that we can teach you how to program in a forum. However, there is an excellent list of good C++ books/tutorials listed at the beginning of this forum. That would be your best …

Member Avatar for Hawkpath
0
177

The End.