565 Posted Topics

Member Avatar for Dudearoo

Easy input/output functions: #include <fstream> #include <sstream> #include <iostream> using namespace std; void open(string filename){ ifstream f_in (filename.c_str(), ios::in); if (!f_in){ cerr<<"Invalid file.\n"; return; } else{ string line; while(getline(f_in, line)){ cout<<line; } } } void save(string filename, string element){ ofstream f_out(filename.c_str(), ios::out); f_out<<element<<'\n'; } Now, you can put in some …

Member Avatar for Lucaci Andrew
0
651
Member Avatar for mahela007

**wikkido5000** Satrt your own thread in which you exaplin your situation. Don't hijack 2 years old threads. You can't mulriply a string '.' with a an integer dottimes, and why would you need that. If you really want that overloading of the console: import time import sys for i in …

Member Avatar for Lucaci Andrew
0
11K
Member Avatar for KY_Fan

KY_Fan no one will do the actual homework/lab asignment for you, but, we can help you. As pyTony said, let's see what you did by now related to this lab asignment. Use what Gribouillis said regardless the equations of a circle which intersects a line. Also, for the graphical part, …

Member Avatar for KY_Fan
0
425
Member Avatar for hughesadam_87

You mean like this?: >>> l ['hi', 'there', 600] >>> newstring='' >>> for i in l: newstring+=str(i) >>> newstring 'hithere600' >>>

Member Avatar for TrustyTony
0
124
Member Avatar for XodoX

The priority queue as an ADT is a container in which elements are stored acordingly to their priority. Have a look at how is implemented in C++: [Click me.](http://www.cplusplus.com/reference/stl/priority_queue/) As for **firdousahmad** you can't access a rear element in the Priority Queue (talking about the C++ implementation). The basic functions …

Member Avatar for XodoX
0
161
Member Avatar for Lucaci Andrew

Hi. So I get this weird error message out from a QT application that i'm creating: 0xc0000005: read access violation at: 0x0, flags=0x0 Basically what I'm trying to do is to set in a QT List Widget an item of type QList Widget Item in which I store two things: …

Member Avatar for Lucaci Andrew
0
3K
Member Avatar for Remy the cook

As firdousahmad said, you have to declare it in your calling function as void function(int *a). Let's see an example: #include <iostream> using namespace std; void ssum(int* ar){ for (int i=0;i<5;i++){ ar[i]=ar[i]+100; } } int main(){ int array[5]={2,5,6,7,8}; ssum(array); for (int i=0;i<5;i++){ cout<<array[i]<<" "; } return (0); } Another way …

Member Avatar for Remy the cook
0
235
Member Avatar for 4evrmrepylrning

> return data, subs 1st mistake: you return a list, but as a return value in which you store that list, you put a variable f. Initialize f as a list, like `f=[]` than put the e, f=subcons(input) import re l = [] def subcons(data): match = re.search(r'(<[a-z]{3})', data) if …

Member Avatar for TrustyTony
0
212
Member Avatar for TrustyTony

Here's the extend part from the Python Documentation: [Extend.](http://docs.python.org/tutorial/datastructures.html#more-on-lists) As for print ('a' 'b' 'c') it's the same with print ('a' 'b' 'c') as for the c='c' print ('a' 'b' c) think of it as c='c' print ('a' 'b' c) where c is a variable, and not a given character. …

Member Avatar for snippsat
1
185
Member Avatar for Vish0203

Well, you can get the CPU Serial Number or the HDD Serial Number. Either way, do a search on google with PC unique identifier as the keyword.

Member Avatar for Vish0203
0
76
Member Avatar for osiron

[Here](http://www.codeguru.com/cpp/cpp/algorithms/article.php/c5123/Permutations-in-C.htm), this should help you.

Member Avatar for osiron
0
184
Member Avatar for prashanthmukund

And also, have a look at [String functions](http://docs.python.org/library/string.html#string-functions) especially at the split one.

Member Avatar for Lucaci Andrew
0
405
Member Avatar for triumphost

[Here](http://www.cplusplus.com/doc/tutorial/classes2/), this should help you. Look at the definition of the constructor.

Member Avatar for deceptikon
0
130
Member Avatar for RonKevin

If you type in `"gi"` it will go to gi, if you type `"q"` will exit the program, and if you type something else will go to the display and the eval functions. int main(){ string ans; for(;;){ cout<<"> "; cin>>ans; if (ans=="gi") gi(); else if (ans=="q") return(0); else{ display(); …

Member Avatar for RonKevin
0
265
Member Avatar for silvesterphilip

Take a look at this thread: [Click Here](http://www.daniweb.com/software-development/c/threads/50370/starting-c-). I bet you'll find something usefull there.

Member Avatar for Lucaci Andrew
0
50
Member Avatar for txhornsfan

On what platform are you programming? Try changing it to another, and use that. Try to run the .exe from the console and see what happens...

Member Avatar for Lucaci Andrew
0
223
Member Avatar for Remy the cook

you should put in a buffer like 1000 lines, copy that into the new file, and clear the buffer, and do it again. You see, after some time, it will fill up the buffer. you can put a condition using of course c++ libraries: while (getline(f_in, line)){ //do stuff if …

Member Avatar for Remy the cook
0
180
Member Avatar for Lucaci Andrew

Inspired by some C and C++ threads regarding finding a specific pattern in a file.

Member Avatar for TrustyTony
0
319
Member Avatar for ashish karna

Duplicate thread: http://www.daniweb.com/software-development/c/threads/426230/calcultor

Member Avatar for Sokurenko
-1
131
Member Avatar for Dudearoo

is better to put as your ofstrema flag the `ios::out` and you could do it simply: #include <iostream> #include <string> #include <sstream> #include <fstream> using namespace std; int main(){ ofstream out("text12.txt", ios::out); cout<<"Insert string: "; string a; cin>>a; out<<a; return (0); }

Member Avatar for Dudearoo
0
141
Member Avatar for RonKevin

this should work for large amount of data: long double pow(long double nr, long double exp){ long double temp=1; for (;exp--;) temp*=nr; return (temp); } for like 23^53=1.48448e+072.

Member Avatar for RonKevin
0
319
Member Avatar for Muro29

here, this should fix it: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ char * list[4] = {"tom", "john", "albert", "lily"}; char answer[10]; printf("enter your name"); scanf("%9s", answer); int i, check=0; for(i = 0; i <4 ; i++){ if(strcmp(answer, list[i])==0){ printf("Found.\n"); check++; break; } } if (!check) printf("Not found.\n"); return …

Member Avatar for Lucaci Andrew
0
135
Member Avatar for boris90

This is a program I did for another topic from the C department, maybe this will help you. Note that it's done in C, but the ideea matters. #include <stdio.h> #include <string.h> #include <stdlib.h> int line_num(char *filename){ FILE *f; char c; int lines = 0; f = fopen(filename, "r"); if(f …

Member Avatar for Moschops
0
664
Member Avatar for new_developer

Here's your code a little bit revise, and with some new implementations. 1st of all, change Borland, because it's old. Ok, so here's the code: #include <iostream> using namespace std; #define MAX 100 struct arr{ int size; int ar[MAX]; }; void popArr(arr &ar); void printArr(arr ar); int main(){ arr arr; …

Member Avatar for Lucaci Andrew
0
167
Member Avatar for firdousahmad

Just replace the condition from line 5 with this one: `if ( argc < 2 )` and it should work fine. Tested on Linux: Ubuntu, and on win 7. On further posts, please post the question as well, because we can't guess that...

Member Avatar for Trentacle
0
93
Member Avatar for ztdep

See, I don't understand this > and the second column is the number of values behind it. but I see you have more than two columns. here's a suggestion: open file for read string c while(getline(fin, c)) read having ' '(space) as delimitter till '\n' @ process every element: 1st …

Member Avatar for Branickiod
0
115
Member Avatar for jemz

If you just want to learn C, you can do it on linux via geedit, joe, or other text editors (vi, vim etc.) Windows: I prefer Eclipse with MinGW (you can have it packed and ready to go by the version for C/C++ developers as you can find [here](http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers-includes-incubating-components/indigosr2) . …

Member Avatar for Lucaci Andrew
0
320
Member Avatar for dwhite12

Here's a way of how you can do it: def read(): l = ["a.txt", "b.txt", "c.txt", "d.txt"] outfile = open("e.txt", "a") for i in l: infile = open(i, "r") outfile.write(infile.read().replace('.2', '[Replace sequence]')) or using pyTony's code: def read(): l = ["a.txt", "b.txt", "c.txt", "d.txt"] for i in l: with open(i, …

Member Avatar for Lucaci Andrew
0
249
Member Avatar for firdousahmad

Have you even bother to search on google?: [Link 1](http://msdn.microsoft.com/en-us/library/yeby3zcb(v=vs.80).aspx) [Link 2](http://www.gnu.org/software/libc/manual/html_node/Opening-Streams.html) [Link 3](http://www.cplusplus.com/reference/clibrary/cstdio/fopen/)

Member Avatar for deceptikon
0
120
Member Avatar for firdousahmad

Here's a quick example of the sorting part, done with gnome sort (stupid sort). #include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 5 void GnomeSort(char* p[SIZE]){ int i=0; char* j; while(i<SIZE){ if (i==0||strcmp(p[i-1],p[i])==-1||strcmp(p[i-1], p[i])==0) i++; else{ j=p[i]; p[i]=p[i-1]; p[--i]=j; } } for (i=0;i<SIZE;i++) printf("%s\n", p[i]); } int main(){ char* p[SIZE]={"Bob", …

Member Avatar for abrarsyed
0
802
Member Avatar for dile

noob26891 it would be better to start your own thread with your problem, than to revive a one year old thread. Also, please use correct indentation. As a side note, why do you use `int main( int argc, char *argv[])` in your main program, but still you don't use the …

Member Avatar for Lucaci Andrew
0
10K
Member Avatar for ASFtlink

Poloblue, I thought you knew by now that if you have a question, you must open your own theread, and not to hijack threads that are older than 3 months. Please, open your thread in order to receive answers to your question. And by your erros I do get that …

Member Avatar for Lucaci Andrew
0
311
Member Avatar for johnadamson

> I need help completing this by tomorrow afternoon!!! > Can anybody write this for me???????? I can tell you not to wait for someone to make your homework/project, because it won't happen. By solving this for you, you gain nothing, and you learn nothing. If you do have something …

Member Avatar for Schol-R-LEA
0
482
Member Avatar for TrustyTony

you could also do it like this def nr(*nrs): nr = "" for i in range (0, len(nrs)): a = str(nrs[i]) nr = nr + a return int(nr) print nr(1, 2, 3, 4, 5, 6) + 100000000 since Python works with strings alot. and if you want to put a …

Member Avatar for TrustyTony
0
298
Member Avatar for bboykk1234

Indeed, what rubberman said. Post your very own attempt of doing this homework, and then, if you are stuck, we will try to help you. > How to find outputs the models with the least price per square meter. You need to do this: > Write a program that accepts …

Member Avatar for bboykk1234
0
153
Member Avatar for Dudearoo

Have you checked this site? http://www.cplusplus.com/forum/unices/9187/ I'm not sure if this would work. #include <fstream> #include <iostream> #include <iterator> #include <string> #include <vector> using namespace std; int main(){ string filename; cout<<"File name: "; cin>>filename; ifstream input( filename.c_str(), ios::binary ); vector<char> buffer((istreambuf_iterator<char>(input)),(istreambuf_iterator<char>())); for (int i=0;i<(int)buffer.size();i++){ if (buffer[i]=='\n') continue; else cout<<buffer[i]; } …

Member Avatar for Lucaci Andrew
0
262
Member Avatar for Dudearoo

This is the complete time, but I don't know if it's what you actually want: #include <ctime> #include <stdio.h> #include <iostream> using namespace std; int main(){ time_t current=time(0); cout<<"Current time is: "<<ctime(&current)<<endl; getchar(); return (0); }

Member Avatar for Dudearoo
0
210
Member Avatar for LatSo

Have a look at this code snippet: http://www.daniweb.com/software-development/cpp/code/425892/prime-numbers-in-range But I wouldn't advise you to take it for grant, because it's a slow and unproducive algorithm. And, beside that, i put it there just as an example to your problem. Try to figure out a better algorithm, because mine is just …

Member Avatar for LatSo
0
716
Member Avatar for Lucaci Andrew
Member Avatar for new_developer

or you can just use stringstream, which is basically i/o-stringstream. #include <iostream> #include <sstream> #include <string> using namespace std; int main(){ string a="a"; int one=1; stringstream concat; concat<<a<<one; //a=concat.str(); //defines the string concat. cout<<concat.str()<<endl; return (0); }

Member Avatar for TrustyTony
0
14K
Member Avatar for Albino

> bool checker(string 11, string 12, string 13, string 21, string 22, string 23, string 31, string 32, string 33); Your problem is rather simple to fix. I don't know exaclty what are those string 11, more speciffic the 11 part means, but, if you want to define a variable …

Member Avatar for Albino
0
367
Member Avatar for spudly1987

That warning appears whenever you are trying to move/delete which has inside of it a prgram that is opened. For example, if you have a music folder, and you want to move it on another partition, but the files are opened in winamp or windows media player, and they are …

Member Avatar for spudly1987
0
201
Member Avatar for reenarankawat

> what is your question? As if you read my mind. Beside posting this long code, what seems to be the problem? I see you use these: #include<iostream.h> #include<conio.h> There are some topics related to that of using conio.h. And in C++ nowdays it's <iostream> not <iostream.h>

Member Avatar for Schol-R-LEA
0
6K
Member Avatar for srg85

Well, 1st of all, you should check the problem info/statement and analyse it a bit. You have to have in the end a 2x2 array, meaning with everything that is in the file, like a maxtrix. I don't know on what os are you trying to code. If you do …

Member Avatar for mridul.ahuja
0
2K
Member Avatar for tomtetlaw

> I want to create a way to define interfaces without having to also write the class declaration that implements it. Are you reffering to those classes from OOP implemented virtual? > For anyone who doesn't know __interface makes all the functions within it automatically public and pure virtual. Indeed, …

Member Avatar for tomtetlaw
0
167
Member Avatar for nee_88

Here p is a char pointer, like char *. Take for example this: #include <stdio.h> char* f(char *p){ printf("%s\n", p); return (p); } int main(){ char *p={"Huga Huga"}; char *l; l=f(p); printf("%s", l); return (0); } Here I have passed the char *p to the function f. As you can …

Member Avatar for deceptikon
0
119
Member Avatar for icefreezer7

Well, either your graphich package is missing some stuff, or you have some prblems with your IDE. And btw, there is a topic on daniweb about this: http://www.daniweb.com/software-development/cpp/threads/180869/include-stdafx.h Here, this might also help: http://forums.codeguru.com/archive/index.php/t-152926.html

Member Avatar for Lucaci Andrew
0
419
Member Avatar for ido098

Sorry pyTony, you forgot the extra ',' on your link, and of that it's not working: Thus, ido098 you should see here: http://wiki.videolan.org/Python_bindings

Member Avatar for TrustyTony
0
138
Member Avatar for Sendy Hipo

Try to use like this: #ifndef ACCOUNT_H #define ACCOUNT_H #include <string> using namespace std; instead of typing std::string. And it's better to include those things only in the Account.h header, like put it there: #include <iostream> #include <fstream> #include <vector> #include <string> #include <stdlib.h> #include <cctype.h> //etc. using namespace std; …

Member Avatar for Sendy Hipo
0
712
Member Avatar for nuclear

I have stuble upon that error myself, and in some cases, it was due to some pointer arithmetic which turned out to point to the 0x0 address. Either you did something, and changed the address of some variable to the 0, meaning the null one, or it's something else. But …

Member Avatar for Lucaci Andrew
0
165

The End.