190 Posted Topics

Member Avatar for rysin

And you don't need these two lines :) [CODE=cplusplus] #include <cstdio> #include <cstdlib> [/CODE] I wouldn't recommend writing always the same, although it's the easiest way And one thing more. I realise you are just starting in C++, but try not to use [ICODE]system("PAUSE");[/ICODE] Just enter this instead of that: …

Member Avatar for Sci@phy
0
98
Member Avatar for kjsalk

Several syntax mistakes: 1. Missing opening bracket after main()! 2. Missing opening bracket after for (instead you have closing bracket on line 13.)! 3. Missing closing for-bracket. 4. Missing closing main() bracket!

Member Avatar for Sci@phy
0
123
Member Avatar for sanushks
Member Avatar for srivtsan

It goes like this: n(0) = 1; n(1) = 1; n(2) = n(1), n(2) //so it's actually two numbers n(3) = n(1), n(2), n(3)... Bottom line is: First two numbers just copy. The print others in a for loop

Member Avatar for Aia
0
97
Member Avatar for mrrko

[QUOTE=mrrko] I mean... how do I calculate with the size in pounds entered by the user, if it is not used in the function? Thanks a lot for the help!![/QUOTE] Confused :confused:

Member Avatar for mrrko
0
409
Member Avatar for vrga
Member Avatar for Sky Diploma
0
126
Member Avatar for joed13k1941
Member Avatar for Sci@phy
0
87
Member Avatar for rysin

Don't use the same template!!! Especially [ICODE]using namespace std;[/ICODE] And yes, you could use: [ICODE]int main(int argc, char* argc[])[/ICODE] But if you don't need arguments you can use: [ICODE]int main()[/ICODE]

Member Avatar for rysin
0
104
Member Avatar for ohara

Ok, first, the code won't compile without [ICODE]#include <iostream>[/ICODE] As for the shadowing. What have you written is: [CODE=cplusplus] int myfunction(int a_number){ int a_number = 4; //do stuffz return some_num; } [/CODE] See the problem? You are creating a variable a_number at the moment the function starts (in line 1 …

Member Avatar for ohara
0
132
Member Avatar for NinjaLink
Member Avatar for maker10

[QUOTE=WaltP;710667]And what does [ICODE]fflush(NULL)[/ICODE] do?[/QUOTE] Flushes everything (like a damn good toilet :) )

Member Avatar for Sci@phy
0
76
Member Avatar for TheBeast32

Just some literature from wikipedia: "In C99, there is a bool type, along with the values true and false, defined in the <stdbool.h>"

Member Avatar for Sci@phy
0
69
Member Avatar for egolovin

It still won't work. You are comparing char with int: getBinary[i] is char, and 1 is int. char != int!!!

Member Avatar for grumpier
0
172
Member Avatar for PhoenixInsilico

[QUOTE=ahamed101;710329]Hi, When I used scanf instead of scanf_s, it printed the output properly... I am not aware of scanf_s... googled it and found it out its some secure version of scanf or something... i use unix and this is available only for MS C I guess... [code=c] scanf("%d %d %d …

Member Avatar for PhoenixInsilico
0
80
Member Avatar for PhoenixInsilico

First: this is not C++ program! Second: scanf_s - what kind of function is that? I don't know, maybe it exists, but I've heard only of scanf. Third: solution is simple, remove blank space between last %d and " [CODE=cplusplus] scanf_s("%d %d %d %d", &a1,&a2, &a3, &a4); // not (%d …

Member Avatar for ahamed101
0
76
Member Avatar for gangsta1903
Member Avatar for gangsta1903
0
2K
Member Avatar for mathrules

You need something like this? [CODE=cplusplus] void Totalinfo( fstream & information, Class& academic) [/CODE]

Member Avatar for mathrules
0
129
Member Avatar for chern4ever

Some changes: [CODE=cplusplus]#include <iostream> using namespace std; const int MAX = 5, MAX2 = 3; class notebook { int num; public : notebook (); //this is wrong. Either write some constructor or don't write it (use default) void set_num( int n ) { num = n; } int get_num() { …

Member Avatar for chern4ever
0
115
Member Avatar for adrian116

s1 -----S1 s1 is instance of S1. ps -----S1 ps is declared as [ICODE]struct S1 *ps;[/ICODE], but since this is C++, not C it should be: [ICODE]S1 *ps;[/ICODE] (because whenever you make class or struct you make a new object, kind of new variable that goes by the name, not …

Member Avatar for adrian116
0
105
Member Avatar for rhoit

I believe he's trying to do something like: [CODE=cplusplus] typedef box MyGreatBeautifulBox; //and use it as: MyGreatBeutifulBox<int> a; MyGreatBeutifulBox<char>b; [/CODE] I don't think it can be done

Member Avatar for rhoit
0
2K
Member Avatar for biggz

You cannot use fact as an loop iterator and as your final variable! Try to see how the program is going to run for x = 3, for example.

Member Avatar for sidatra79
0
234
Member Avatar for Niner710

If you put some struct inside class, then it is defined only inside that class! The difference is between declaring another datatype, and declaring another instance! If you declare datatype inside class, it's not available outside of that class! If you declare datatype outside class, it's available inside and outside …

Member Avatar for ArkM
0
124
Member Avatar for Tr1ckst3rNcag3d

It's best that you don't use array, but binary tree to store info (fastest way to search if you have a lot of numbers stored). Check this out: [URL="http://www.cplusplus.com/reference/stl/set/"]http://www.cplusplus.com/reference/stl/set/[/URL]

Member Avatar for Tr1ckst3rNcag3d
0
96
Member Avatar for thenic
Member Avatar for brezzler89
Member Avatar for unk45

After each [ICODE]cin>>something[/ICODE], add [ICODE]cin.ignore(80, '\n')[/ICODE]; That's because "cin>>" takes what he needs (in your case character) but leaves everything else including newline char, so you have to get rid of it

Member Avatar for mcriscolo
0
94
Member Avatar for Niner710

Structure doesn't have restricted acces. You have "myVoltageValues", so simply do: >myVoltageValues.Vcc = 3.14; >myVoltageValues.TblkLoopEnb = 3; >myVoltageValues.Blah = 2.3333333;

Member Avatar for mcriscolo
0
157
Member Avatar for Niner710

It isn't strictly related to namespaces. If you write a function outside of class it belongs, you have to use :: operator! Otherwise, compiler won't know if it's some other function or that particular one.

Member Avatar for ArkM
0
129
Member Avatar for jared_masc

Ok, what were you trying acomplish with this: >printf("%s", getInputByscanf); First, that getInput... is function, so you have to call it with "()" brackets. But still, it's nonesence

Member Avatar for stilllearning
0
247
Member Avatar for ahamed101

[QUOTE=ahamed101;702380]Hi Everyone, I know conio.h is not available in Unix. I want to use getch(). Using curses.h needs causes the screen to clear which I don't want. I found a code snippet (source : internet) using termios, it works, the thing is I need to press enter/or any other key …

Member Avatar for ahamed101
0
1K
Member Avatar for thenic

You obviously have three options about kwh, and using if-else is wrong approach. Instead use: [CODE=cplusplus] if (kwh <= 20){ //do some coding here } else if (kwh > 20 && kwh <= 40){ //do other code here //notice that I wrote here kwh > 20, not kwh >= 20 …

Member Avatar for thenic
0
100
Member Avatar for JackDurden

The answer is simple: If you are using templates, you can't have header and source code. Everything has to be in one file.

Member Avatar for Sci@phy
0
88
Member Avatar for totalnoob

How do you expect it to work when you write "complex" into file, and try to get "float" out of it?

Member Avatar for totalnoob
0
80
Member Avatar for chanda gul

I'm not sure about the code itself, but the problem can be as simple as: '' is sort of escape key inside string ("\n", "\t", "\a"...) If you want to really type '', you have to write: "\\". So, instead "C:\*", try "C:\\*"

Member Avatar for chanda gul
0
151
Member Avatar for mikeregas

First: I believe you know what functions are? Or at least you should. Well, recursion is when you call some function inside itself. This is not a recursion! Second: If you want to make a simple menu (like that what you said, y to enter another, n to exit) you …

Member Avatar for stilllearning
0
74
Member Avatar for Sky Diploma

I made slight adjustment: [CODE=cplusplus] sky.erase(sky.begin()+x); [/CODE] More on: [URL="http://www.cplusplus.com/reference/string/string/erase.html"]http://www.cplusplus.com/reference/string/string/erase.html[/URL] EDIT: oh yes, x <= sky.size() is wrong, should be x < sky.size()

Member Avatar for Sky Diploma
0
99
Member Avatar for chococrack

If you want to pass POINTER to current object, then it is simply [ICODE]this[/ICODE], and not [ICODE]*this[/ICODE]

Member Avatar for Narue
0
280
Member Avatar for terme22

[URL="http://www.cplusplus.com/doc/tutorial/pointers.html"]http://www.cplusplus.com/doc/tutorial/pointers.html[/URL] Check out Dereference operator (*)

Member Avatar for chococrack
0
127
Member Avatar for StephanJos

Have you read your errors? No 1: invalid preprocessing directive #incluce Have you heard of INCLUCE? I haven't No 2: expected nested-name-specifier before "namespce" Have you heard of NAMESPCE? I haven't No 3: namespce again, and so on...

Member Avatar for Ancient Dragon
0
190
Member Avatar for jeevsmyd
Member Avatar for J-son

fflush should not work with input stream! But in some compilers it does! That's all

Member Avatar for abhijeetcn
0
148
Member Avatar for unk45

else if{type = 'exit') First, there's some syntax error, but that's different story. type is [B]char variable[/B]. How can it store 'exit'? Besides, what is 'exit'? (answer: nothing) Try to change it like, if user types 'x', or 'e'... or simply else (not 1 or 2)

Member Avatar for stilllearning
0
232
Member Avatar for Talli

You need two for-loops. First one (outer) should count rows, while inner one should (depending of the row it's in) count columns

Member Avatar for Talli
0
133
Member Avatar for mugun
Member Avatar for sunveer

How's that a programming question? Here: 1 2 3 4 . 6 7 8 . . 1 2 . . . 6 That's uper triangle

Member Avatar for ArkM
0
97
Member Avatar for luisvega
Member Avatar for san_sarangkar
Member Avatar for Freaky_Chris
0
195
Member Avatar for lomo

What is this: [CODE]if (genArray[i] == "ACG")[/CODE] genArray[i] == some_character, not some_string! The code isn't that simple... You have to check char by char if 'A' then 'C' then 'G' occurs! And of course, typos that Salem told you :)

Member Avatar for lomo
0
253
Member Avatar for Se7Olutionyg
Member Avatar for Jennifer84

Actually, that is a list, not a vector. Minor differences, but still. Here's one way (matrix of strings): [CODE=cplusplus] typedef vector<string> row; vector<row> *vec1 = new vector<row>; [/CODE]

Member Avatar for Jennifer84
0
169

The End.