565 Posted Topics

Member Avatar for brahle

On my laptop: cout: 0.89 printf: 67.89 Operating System: Windows 7 Ultimate 64-bit (6.1, Build 7601) Service Pack 1 (7601.win7sp1_gdr.120330-1504) Processor: Intel(R) Core(TM) i3 CPU M 330 @ 2.13GHz (4 CPUs), ~2.1GHz Memory: 4096MB RAM I'll try on my PC, to see if there's any difference between them.

Member Avatar for neithan
0
2K
Member Avatar for DangleSauce19

If the code relies on printing out remainders in base 16, why don't you use the hex part of the cout? int main(){ int remainder=159%16; cout<<remainder<<endl; cout<<hex<<remainder<<endl; cout<<159%16; return (0); } This will print the letter `f`. For more information about printing out or working with hexadecimal check this website: …

Member Avatar for WaltP
0
2K
Member Avatar for Grandiago

Hope this helps. Note that I didn't write it in Turbo C++, you'll have to make the right adjustments. Also, you might change the `char file[256]` line with `char* file="C:\Documents and Settings\Migs\Dextop\test.txt"` so that it will open the file directly from your dextop. I took the liberty to make some …

Member Avatar for WaltP
0
167
Member Avatar for ConfusedLearner

as **deceptikon** pointed out: #define radius Here you must give radius a value (as the point of this assignment illustrates: "Program illustrating the use if #defines"). `#defines` works as macros, here you gave `PI` a value which will be held throughout the entire program, thus doing the same with radius. …

Member Avatar for Lucaci Andrew
0
224
Member Avatar for markwiering

Not to be pricky or such but **markwiering**, you should listen to these fine gentlemen, because they really know what they are talking about. Frankly when I look at your source code I see a lot of if statements whereas some other implementation would have saved your processor time/life etc. …

Member Avatar for markwiering
0
1K
Member Avatar for HacruLeian

like **iamthwee** said, you should use a class in which you'll store as elements each of your requirements: So you'll need some strings for the project name, supervisor name and student name, and some integer for the id. After you do that class, let's call it `ToBeStored`, you should use …

Member Avatar for Bob
0
104
Member Avatar for streetalex310

here, this might help you: #include <iostream> #include <string> #include <fstream> #include <sstream> using namespace std; int main(){ string file; cout<<"Insert file: "; cin>>file; ifstream fin(file.c_str(), ios::in); string line; if(!fin){ cerr<<"Can't read file "<<file<<endl; return (0); } else{ cout<<"Text: \n"; while (getline(fin, line,' ')){ stringstream token(line); int to_hex; token>>hex>>to_hex; cout<<(char)to_hex<<' …

Member Avatar for WaltP
0
161
Member Avatar for Lucaci Andrew

Ok, so, this code snippet is a reply to this thread: http://www.daniweb.com/software-development/cpp/threads/425821/prime-number-c From what I understood form the OPs request, is that, he wanted an algorihm which would check for prime numbers in a given range, applying these conditions: a number is to be considered valid if: a. the number …

Member Avatar for RainbowMatrix
0
602
Member Avatar for angelineang

Another thing you could do, having in consideration the fact that your problem, as you identified, resides in the main menu part of your program, you could change the approach of the menu. You could use instead of the `switch case` statements a simply string validation menu: #include <iostream> #include …

Member Avatar for Lucaci Andrew
0
206
Member Avatar for theju112

This might help you: #include <iostream> using namespace std; int main(){ cout<<'a'+0; //prints out the ascii number of character 'a' return (0); }

Member Avatar for Lucaci Andrew
0
153
Member Avatar for Venaplex

I don't think there is that kind of tool, but searching on google won't kill you. And on the other ideea of yours, making an online convertor, you being just a beginner in java and c/c++ would make things harder. Maybe it's better to start with something easier, maybe from …

Member Avatar for nmaillet
0
114
Member Avatar for Bumpehh

A slightly different approach, or not... here it goes anyway: /* * game.cpp * game.cpp is licensed under GNU GENERAL PUBLIC LICENSE * Created on: Aug 15, 2012 * Author: sin */ #include <iostream> #include <string> #include <stdio.h> #include <stdlib.h> #include <time.h> using namespace std; int plays=0, comps=0; int computer(){ …

Member Avatar for m4ster_r0shi
0
1K
Member Avatar for Harshini Divya

Here's the pseudocode. class Rectangle int height, width public Rectangle(initial_height, initial_width) height=initial_height width=initial_width end_Rectangle getArea() getArea=height*width end_getArea end_class main height=input height width=input width Rectangle rt(height, width) print Area=rt.getArea end_main

Member Avatar for Lucaci Andrew
-2
207
Member Avatar for clarisaduta

> public String changeBadWords(String string, Collection<String> badWords) { > for (String badWord : badWords) { > string = changeBadWord(string, badWord); > } > return string; > } > private String changeBadWord(String sentence, String badWord) { > return sentence.replace(badWord, censor(badWord)); > } > private String censor(String badWord) { > for (String …

Member Avatar for Lucaci Andrew
0
300
Member Avatar for jakkaprashanthi

As **np complete** said, post some code first, so that we see you've tried. We won't solve your homework, because that won't help you at all. If you want to become a programmator you'll have to start programming, and these kind of homeworks are just the thing you need in …

Member Avatar for Lucaci Andrew
0
158
Member Avatar for prglili5994
Re: C++

And have you even try to solve this homework? Or are you hoping for us to solve it, and than to just present the result to your teacher? Show us that you've tried, show us where are the issues and than we'll try to help you.

Member Avatar for Lucaci Andrew
0
69
Member Avatar for tony75

Maybe you can think your program as this: a class Library in which you hold objects books and some kind of connection (talking about the loan part) with the customers. This connection will be for the loan part, as each object book can be loan or is loaned. Each book …

Member Avatar for tony75
0
685
Member Avatar for Sendy Hipo

Have a look at this snippet: http://www.daniweb.com/software-development/cpp/code/427923/simulation-of-functions-from-stlvector

Member Avatar for Sendy Hipo
0
961
Member Avatar for gem.gonzales.9

Here's the pseudocode: function getpass() char choice char passwd[lenght] do @ ask for password passwd<-input @ ask for a repeat choice<-input while choice = 'n' end_do_while end_function

Member Avatar for WaltP
0
160
Member Avatar for Lucaci Andrew

Here's some simulation of the basic push_back and pop_back functions from stl vectors, "inspired" by this thread: http://www.daniweb.com/software-development/cpp/threads/427912/question-about-a-simple-vector-class-template

Member Avatar for Rashakil Fol
0
500
Member Avatar for Lord_Migit

as **deceptikon** said, you should stick with the std::string objects. #include <iostream> #include <string> using namespace std; int main(){ string choice; cout<<"A or B?"; cin>>choice; if (choice=="A") cout<<"A\n"; else if (choice=="B") cout<<"B\n"; else cout<<"Invalid command.\n"; return (0); } Here's a quick example of how you can compare strings, via the …

Member Avatar for Lord_Migit
0
196
Member Avatar for speakon

C++ tutorial about file i/o: http://www.cplusplus.com/doc/tutorial/files/ C++ tools: [I/O library](http://www.cplusplus.com/reference/iostream/) [manipulators](http://www.cplusplus.com/reference/iostream/manipulators/) Time retrival: [C time](http://www.cplusplus.com/reference/clibrary/ctime/ctime/) [C time library](http://www.cplusplus.com/reference/clibrary/ctime/) File parshing: [File parshing example.](http://cs.dvc.edu/HowTo_Cparse.html) Other Daniweb threads: http://www.daniweb.com/software-development/cpp/threads/426579/file-io-.txt-read-error#post1824833 http://www.daniweb.com/software-development/cpp/threads/426316/search-whole-file-for-a-complete-string-c#post1823366

Member Avatar for Lucaci Andrew
0
173
Member Avatar for omkar_more

Easy done via strings. #include <iostream> #include <string> using namespace std; int main(){ string name; cout<<"Insert your name: "; cin>>name; cout<<"Hello "<<name<<".\n"; return (0); }

Member Avatar for Lucaci Andrew
-1
140
Member Avatar for rdx05

Here, this sould fix it: #include<iostream> #include<string> using namespace std; int main(){ char array[5][5]; int i=0,j=0; string z[5]={"abdg","ygur","guqh","asdf","sent"}; for(i=0;i<5;i++) for(j=0;j<4;j++){ array[i][j]=z[i][j]; cout<<"\narr["<<i<<"]["<<j<<"]="<<array[i][j]; } for (int i=0;i<5;i++) array[i][4]=0;//clears the buffer for unwanted characters. for(i=0;i<4;i++) cout<<"\narr="<<array[i]<<endl; return (0); } I changed the array type to char, as **ravenous** suggested, because you're accessing …

Member Avatar for rdx05
0
207
Member Avatar for WolfShield

At first, as all websites, Facebook had an 'enemies' button, just as the 'friends' button, but soon after the grand opening of the website, it's core was failing due to the fact that no1 could put Chuck Norris on their enemy list, not even on a virtually list.:D

Member Avatar for itzarun
0
1K
Member Avatar for peterparker

as **pyTony** said, `file` as a variable name is bad because `file` as a name is used inside Python do denote i/o file stream objects.

Member Avatar for peterparker
0
209
Member Avatar for learner_new

think of this like this: #include <iostream> using namespace std; int main(){ char a='a'; cout<<"Char a: "<<a<<endl; char* p=new char(a); cout<<"Char* p(points to a): "<<*p<<endl; char** pp=new char*(p); cout<<"Char** pp (points to p which points to a): "<<**pp<<endl; return (0); } Also you can do a 2x2 matrix out of …

Member Avatar for NathanOliver
0
6K
Member Avatar for Deena1977

And your question is? I can tell you straight from the beginning: We don't solve homeworks, but we can help. Liniar search algorithm, this is the pseudocode: number_of_times<-0 i<-0 intput<-given input while input!=array[i] do number_of_times++ i++ end_while if number_of_times=20 then print element not found end_if It's not that hard to …

Member Avatar for Lucaci Andrew
0
117
Member Avatar for msrikanth

try this: [useradd](http://nixcraft.com/getting-started-tutorials/3293-create-new-user-account-ubuntu-linux-command-line.html#post23762) just found it outa google...

Member Avatar for rch1231
0
354
Member Avatar for vh1nc3_25

And presumably you want it in a nice format, with some comments rite? Well, I think that's not gonna happen. You see, this sounds like a homework/lab assignment, and here, at Daniweb, we don't solve homeworks for others. Out goal here is to help those who are in need or …

Member Avatar for Lucaci Andrew
0
133
Member Avatar for Lucaci Andrew

This is a program which I made back in the beginnings when I was trying to figure out how to work with strings, and how to work with files. This is suppose to format a C++ code, for example if the syntax of an if statement is if (condition) { …

Member Avatar for Lucaci Andrew
0
368
Member Avatar for grh1107

Well, line 42 and 45 you're trying to declare a function in another function, and that's not allowed. void RMatrix::RepMatrixf() { const int MAX = 100; // PROBLEM STARTS BELOW void RepMatrix (int NDR, int size, int PosIR, int calls) but by looking to your code, you want to do …

Member Avatar for mike_2000_17
0
3K
Member Avatar for alaa sam

Have you checked this thread? [Click Here](http://www.daniweb.com/software-development/c/threads/50370/starting-c-) it's at the top of the C threads.

Member Avatar for madelinekim
0
325
Member Avatar for triumphost

The basic ideea of your problem is called a [Permutation](http://en.wikipedia.org/wiki/Permutation). There are numerous methods of doing that, maybe check in the CS department of the link for some concrete algorithms. >How do I start? Or better yet Where? take **WaltP**'s example...

Member Avatar for Lucaci Andrew
0
107
Member Avatar for on93

Here's the pseudocode, a little bit of thinking wouldn't have hurt you would it? subalg. printChristmasTree(){ for (i<-0, i<5) do for (j<-0, j<=i*2) do for (k<-5, downto i) do if (j=0) then print space end_if print '*' end_for print new line end_for @print base of the tree end_for end_Subalg.

Member Avatar for Lucaci Andrew
0
293
Member Avatar for learner_new

Here's a quick example: #include <iostream> #include <string> #include <fstream> using namespace std; int main(){ string filename; ifstream fin(filename.c_str(), ios::in); if (fin.is_open()){ string line; while (getline(fin, line)){ cout<<line; } } else cout<<"Invaild file."; return (0); } Getline will take the input from the file either till '\n' appears or the …

Member Avatar for learner_new
0
235
Member Avatar for Remy the cook

Since you're posting in a C++ thread, why don't you use C++ functions to work with? I'm just saying, it might help you.

Member Avatar for Lucaci Andrew
0
224
Member Avatar for kase20

> int argc,char *argv[] 1st of all, why do you use that? I don't see in your program nothing related to that. 2nd: this is an example of how you should do it, if I understood corectly. Here I'm not using any char 2x2 array, but I do simulate one. …

Member Avatar for kase20
0
155
Member Avatar for jeevsmyd

well by fork() you'll create a child process. the pipe works like this: on one end you write something and on the other end you read. the pipe is done like this, I'll write it in pseudocode: int a2b pipe(a2b) if fork()==0 then write(a2b[1], information, size) exit(0) endif wait(0) read(a2b[0], …

Member Avatar for Lucaci Andrew
0
210
Member Avatar for lxXTaCoXxl

Have you checked this code snippet? http://www.daniweb.com/software-development/cpp/code/425707/simple-string-to-int-and-int-to-string-conversion

Member Avatar for NathanOliver
0
238
Member Avatar for poloblue

I will hant it in pseudocode, it's not too hard to figure it out by yourself: i<-0; while i != given_input_number do j<-0 while j != i do print * increment(j) end_while print new line increment(i) end_while as cscgal said you have only the outer loop, so you need to …

Member Avatar for poloblue
0
1K
Member Avatar for oggiemc

Type in the cmd the following lines: gcc --version g++ --version make --version If either 1 of them sais that the program is not found, you'll have to reinstall MinGW.

Member Avatar for Lucaci Andrew
0
603
Member Avatar for SCass2010

Here's a way of doing it using string, and C++ items: #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; int main(){ string str="HEllo*world*hello.", split; vector<string> all; istringstream token(str); while (getline(token, split, '*')){ all.push_back(split); } for (int i=0;i<(int)all.size();i++){ cout<<all[i]<<endl; } return (0); } The all vector will contain …

Member Avatar for L7Sqr
0
2K
Member Avatar for alan91

As **mike_2000_17** said: we can help you only if you show us some code, or some attempts of doing the actual homework. In your program you'll need a container in which you'll store the integers. You will need after that another 3 distinct integers, one which will hold the smallest …

Member Avatar for Lucaci Andrew
0
333
Member Avatar for XodoX

Well depending on what you think when you're talking about input redirection. This can be either putting the input of a file into an array, or putting the input given from the keyboard into an array? You got that % a.out < inputfile off this site: http://www.cs.bu.edu/teaching/cs111/spring-2000/file-io/ but did you …

Member Avatar for Lucaci Andrew
0
270
Member Avatar for HTMLperson5

> if pl_move == "skip" or "Skip" or "SKIP": As pyTony said, the if statement will be always true. You'll need to do it like this: if pl_move == "skip" or pl_move=="Skip" or pl_move=="SKIP": the condition impose that you should check the equality for every choice of pl_move. As for …

Member Avatar for HTMLperson5
0
272
Member Avatar for triumphost

I think you can't pass a vector as `const vector<string> &vect` and still resize it, because the `const` argument insures that the element passed will not be change, whereas resizeing will change it, so it will yield a compiler error. Passing the vector as `vector<string> vect` will pass a copy …

Member Avatar for mike_2000_17
0
3K
Member Avatar for silvercats

**firdousahmad** indeed, but the difference between `int main() { return(0);}` and `void main(){}` is alot more than the return type. Read more about this question [here.](http://www.cplusplus.com/forum/beginner/19979/) `#include <iostream>` includes in your program the library iostream (Standard Input / Output Streams Library). Read more about that [here.](http://www.cplusplus.com/reference/iostream/) About the `using namespace …

Member Avatar for silvercats
0
874
Member Avatar for XodoX

Here's a quick and dirty way to store the items position. I'm using a vector for that. #include <iostream> #include <vector> using namespace std; int main(){ int numbers[100]; vector<int> divisors; for (int i=0;i<100;i++){ numbers[i]=i+200; } for (int i=0;i<100;i++){ if (numbers[i]%7==0) divisors.push_back(i); } for (int i=0;i<(int)divisors.size();i++){ cout<<"Number divisible with 7: "<<numbers[divisors[i]]<<"\nPosition …

Member Avatar for triumphost
0
172
Member Avatar for Archuom

**Archuom**: there are plenty examples on the forum, just type file i/o in the search box. **laith al hamed** what is your business here? If you do have some questions please make a thread of your own in which you explain your needs and struggles.

Member Avatar for Lucaci Andrew
0
921

The End.