1,171 Posted Topics

Member Avatar for tux4life

Hi, When you post a new code snippet, it is always announced multiple times on Daniweb's index page, is this normal or is this just an unreported bug?

Member Avatar for tux4life
0
224
Member Avatar for inegames

Why do you use old-style header for the [B]math[/B] library? [ICODE]#include <math.h>[/ICODE] in C++, the new-style headers are preferred: [ICODE]#include <cmath>[/ICODE] :P

Member Avatar for tux4life
0
83
Member Avatar for brightsolar

Is it so difficult to post using code tags? It's nearly mentioned everywhere: in the forum announcement which you didn't read, on the background of the text box where you type in your message when making a post, above the forum announcements, in the '[URL="http://www.daniweb.com/forums/thread78223.html"]Read this [B]before[/B] posting[/URL]'.

Member Avatar for brightsolar
0
238
Member Avatar for mostermand

[QUOTE]1. When passing objects between each other is it preffered to use references if not what then? 5. When allocating resources should you always do it inside of a class?[/QUOTE] To answer your first question: yes, the preferred way of passing objects is [I]pass by reference[/I] In your fifth question …

Member Avatar for mostermand
0
145
Member Avatar for FaMu

Just get the ASCII codes from the file (as a number), then put it in a char-variable and print it to the screen or append it at the end of the string variable where you want to put the converted string in :)

Member Avatar for FaMu
0
167
Member Avatar for wnrqkflwnrqkfl

Don't use [ICODE][B]!inf.eof()[/B][/ICODE] as a condition in a loop for reading a whole file: [CODE] void get_graph ( string const &filename, NodeMap &node_map ) { ifstream inf ( filename.c_str() ); string from, to; double weight; while ( [B]!inf.eof()[/B] ) { inf >> from >> to >> weight; if ( inf.good() …

Member Avatar for Dave Sinkula
0
3K
Member Avatar for wnrqkflwnrqkfl

Start with these: [LIST] [*][URL="http://www.daniweb.com/forums/announcement8-3.html"]Forum Announcement[/URL] [*][URL="http://www.daniweb.com/forums/thread78223.html"]Read this [B]before[/B] posting[/URL] [/LIST] Then you should explain what you mean with: [I]...output should be in alphabetical order...[/I] (give an example) Do you mean the following? [CODE][U]File looks like:[/U] [I]lalal nn[/I] [U]Output should be:[/U] [I]aalllnn[/I][/CODE]

Member Avatar for tux4life
0
278
Member Avatar for pxndx

Or read the following (IMO the best) free e-book about C++ programming: [URL="http://msdn.microsoft.com/en-us/beginner/cc305129.aspx"]http://msdn.microsoft.com/en-us/beginner/cc305129.aspx[/URL] :)

Member Avatar for ArkM
0
147
Member Avatar for shuda009

What do you think of: [ICODE]cin >> [I]your_command[/I] >> [I]your_integer_parameter[/I];[/ICODE] ?

Member Avatar for tux4life
0
178
Member Avatar for richymac

[QUOTE=richymac;872680]im trying to write a cg pixel shader and just want to generate a random number too offset the colour of a pixel is there something i need to include, i tried using rand() but gave me errors thanks in advance[/QUOTE] [B]rand()[/B] and [B]RAND_MAX[/B] are both defined in [B]cstdlib[/B], so …

Member Avatar for Stinomus
0
328
Member Avatar for newbiecoder

How I would do it: [LIST=1] [*]Create a temporary variable of the same length as the one were you want to delete the spaces from [*]Use a for-loop to loop through the whole string where you want to delete the spaces from, every time you check whether the read character …

Member Avatar for ArkM
0
118
Member Avatar for gsingh2011

[QUOTE=gsingh2011;875232]How would I make a program that can insert text into a text field in another program? Or click a button in another program?[/QUOTE] You could implement your application as one which communicates with it's own instances over a network, then you can let your program send messages to the …

Member Avatar for Stinomus
0
126
Member Avatar for kimbirdy09

[QUOTE=kimbirdy09;875766]ok so could you give me some ideas/examples please, am really struggling with this part Thanks[/QUOTE] Take a look at the following: [LIST] [*][URL="http://www.daniweb.com/forums/announcement9-3.html"]Forum announcement[/URL] [*][URL="http://www.daniweb.com/forums/thread78223.html"]Read this [B]before[/B] posting[/URL] [/LIST] >Push it and put your code inside it. Use different code tags for each of your classes Or just paste …

Member Avatar for Zibo
0
100
Member Avatar for ganbree

Does [B]Input.txt[/B] exist? (remember that it's case sensitive) Replace this (line 26-30): [CODE] while(!Input.eof()) { getline(Input, Line); cout << Line << endl; }[/CODE] with this: [CODE] while(getline(Input, Line)) cout << Line << endl; [/CODE] or this: [CODE] getline(Input, Line); while(!Input.eof()) { getline(Input, Line); cout << Line << endl; }[/CODE]

Member Avatar for Narue
0
140
Member Avatar for Mr Bin

[QUOTE=Mr Bin;875845]I will try. because I am a Vietnamese, so be able to write non-standard English. You please guess.[/QUOTE] We don't care about the fact whether English is your native language or not(*), it's [B]your effort[/B] which counts ! Let me clarify this: You have posted your assignment, but what …

Member Avatar for tux4life
0
115
Member Avatar for Se7Olutionyg

Here's an example on how to get the time: I don't know whether it's good to recommend you, but you can also achieve the same by using [B]scanf[/B] from the standard C library ([B]cstdio[/B]): [CODE] int hours, minutes, seconds; scanf("%d%*c%d%*c%d", &hours, &minutes, &seconds); [/CODE] or you could rewrite it in …

Member Avatar for tux4life
0
108
Member Avatar for zack.walters

[QUOTE=Luckychap;874631]Very common mistake in for loop: [code='c'] for(i=0; inputDone == 'y'; i++) [/code] did u get this!![/QUOTE] Don't blame him for making a mistake, everyone makes mistakes (me too), let me explain: If you write [ICODE]for(i=0; inputDone [B][COLOR="Red"]=[/COLOR][/B] 'y'; i++)[/ICODE] with one '=' sign then you're doing an assignment to …

Member Avatar for yun
0
147
Member Avatar for tonig_ccc

[QUOTE=tonig_ccc;874644]i wanted to ask you guys for some help i use microsoft visual studio 9.0 and i have downloaded hotspotter but it resulted it was all a source now i dont know how to compile it with mocrosoft visual studio any help???????????[/QUOTE] You could start by giving us the link …

Member Avatar for siddhant3s
0
134
Member Avatar for nanchuangyeyu

[QUOTE=nanchuangyeyu;874570]Hi, I am trying to declare a 3D array with the size of 6,400 and 400 in each dimension using the code as following: [CODE] short matrix[6][400][400]; [/CODE] So what's wrong with this code?[/QUOTE] Nothing, with me it compiles and runs fine :) Try compiling it as a [B]release[/B] executable, …

Member Avatar for ArkM
0
212
Member Avatar for phoenix911

[ICODE]#include <stdlib.h>[/ICODE] is old style C++, if your compiler supports it you should consider using the new-style header file: [ICODE]#include <cstdlib>[/ICODE] BTW, Read the third remark in my signature :P

Member Avatar for siddhant3s
1
202
Member Avatar for Sturm
Member Avatar for John A
-1
122
Member Avatar for sanushks

So, you want to convert a character string to an integer variable, try [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/"]atoi[/URL] ! example: [CODE] char num[] = "5269"; int i; i = atoi(num); // integer variable i now holds the number 5269 [/CODE]

Member Avatar for sanushks
0
160
Member Avatar for Daria Shmaria

>Alternatively, is there a way to convert from string to char * (not convert from string to const char *, as c_str() does)? Yes there is: [CODE=C++] string s1 = "Hello World"; char *s2 = new char[s1.size()+1]; strcpy(s2, s1.c_str()); delete s2; [/CODE] explanation of the code: [CODE] line 1: declare …

Member Avatar for Daria Shmaria
0
30K
Member Avatar for anujsharma

Is reviving a thread like this one really a good idea? I don't think so :( the first post is at least six years ago :P Edit:: I just see that the posts are moved to a new thread, so all what's above in this post doesn't apply anymore :)

Member Avatar for BestJewSinceJC
0
117
Member Avatar for javaAddict

I would suggest you to go to your local bookstore and buy that one :) (both books are exactly the same, I compared the ISBN code)

Member Avatar for jephthah
0
101
Member Avatar for BlackStar
Member Avatar for BlackStar
0
417
Member Avatar for elitedragoon

If you only want to convert integers to a string, then you should try [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/"]itoa[/URL] :)

Member Avatar for ArkM
0
146
Member Avatar for vasek

First some remarks on your code: [CODE] while(!soubor.eof()) { getline(soubor,radka); if(soubor.eof()) break; . . . [/CODE] can be replaced by: [CODE] while(getline(soubor,radka)) { . . . [/CODE] and [ICODE]while (pch != NULL)[/ICODE] is actually the same as [ICODE]while (pch)[/ICODE] :P Is the matrix always of the same dimension?

Member Avatar for homeryansta
1
132
Member Avatar for youngfii

[CODE=C++] ages[0]='1'; ages[1]='2'; ages[2]='3'; ages[3]='4'; [/CODE] won't put the numbers 1, 2, 3 and 4 in the array :) You'll have to write [CODE=C++] ages[0]=1; ages[1]=2; ages[2]=3; ages[3]=4; [/CODE] Or you can truncate it by directly initializing the array: [ICODE]int ages[4] = {1,2,3,4};[/ICODE] [ICODE]while (ages[4] != 1,2,3,4);[/ICODE] should be: [ICODE]while …

Member Avatar for arshad115
-1
110
Member Avatar for madtorahtut

Take a look at the following example: [CODE=C] #include <stdio.h> void print_el(char **p, int el) { printf("%s\n", p[el]); } int main(void) { char *blah[] = { "string1", "string2" }; print_el(blah, 1); print_el(blah, 0); return 0; } [/CODE] output is: [CODE] string2 string1 [/CODE] >how can I move to the next …

Member Avatar for madtorahtut
0
334
Member Avatar for kailisr

[QUOTE=Dave Sinkula;872343][code]6.8.5 Iteration statements Syntax iteration-statement: while ( [COLOR="Red"]expression[/COLOR] ) statement do statement while ( expression ) ; for ( expressionopt ; expressionopt ; expressionopt ) statement for ( declaration [COLOR="Red"]expressionopt[/COLOR] ; expressionopt ) statement[/code][/QUOTE] According to the C++ standard it's: [CODE] [U]6.5 Iteration Statements[/U] iteration-statement: while ( [COLOR="Green"]condition[/COLOR] ) …

Member Avatar for tux4life
0
128
Member Avatar for Arumugams

[QUOTE=Arumugams;872879]Hi, I am new for writing plugins.Dont know how to start.Can any body provide link or sample codes for plugins.[/QUOTE] Google on [B]Browser Helper Objects[/B] :)

Member Avatar for tux4life
0
54
Member Avatar for arenq

[QUOTE=amrith92;872827]Do you mean STL's [ICODE]std::stack[/ICODE], or something of your own creation?[/QUOTE] As he's talking about iterators, I assume he means the stack template from STL :)

Member Avatar for arenq
0
82
Member Avatar for mohiit

Hi, mate, this forum isn't made for 'testing' how your image is displayed :angry: !! By the way, you even don't have a question and this thread isn't Java related !

Member Avatar for tux4life
0
45
Member Avatar for lifeworks

[ICODE]for($i = 86400; $i < 604900; [COLOR="Red"][B]$i + 86400[/B][/COLOR])[/ICODE] has to be [ICODE]for($i = 86400; $i < 604900; $i +[B][COLOR="Green"]=[/COLOR][/B] 86400)[/ICODE] (otherwise your loop index always stays [B]86400[/B] :)) :P

Member Avatar for lifeworks
0
101
Member Avatar for Gurdinho

Take a look at [URL="http://www.daniweb.com/code/snippet1179.html"]this[/URL] code snippet :) Or you could use a vector.

Member Avatar for ArkM
0
100
Member Avatar for cool_aj

Did you select 'C Project' in the 'New Project' Dialog ? Otherwise reinstalling Dec-C++ might solve the problem :)

Member Avatar for cool_aj
0
130
Member Avatar for Duki

[QUOTE=adatapost;872278]tux4life >Unportable rubbish which doesn't work. adatapost>Oh!!! Buddy you should have to test this code before judge.[/QUOTE] I have tested it before I judged, I'm not stupid ...

Member Avatar for tux4life
0
250
Member Avatar for Sune

A [U]condition[/U] is something which is brought down to be [ICODE]true[/ICODE] or [ICODE]false[/ICODE]. Most of the time, an [U]expression[/U] can be evaluated to be [ICODE]true[/ICODE] or [ICODE]false[/ICODE], [ICODE]false[/ICODE] stands for the value [ICODE]0[/ICODE] and [ICODE]true[/ICODE] stands for all the other possible values :)

Member Avatar for e.shankar87
0
228
Member Avatar for DeathWalker101

If you program in assembler, knowledge of a high-level/middle-level programming language is already assumed before you even start learning assembly, and you don't know how a simple loop works in Java? :P If your question is how to do this in assembly, you should have posted/started this thread in the …

Member Avatar for tux4life
0
84
Member Avatar for cigur

You can use a [B]struct[/B] in practically (this means: in most cases, but not always) the same way as a [B]class[/B] (because technically structs are classes in C++), consider the following example: [CODE] [B][COLOR="Green"]struct[/COLOR][/B] s { void disp(); s(int num); [COLOR="Green"][B]private:[/B][/COLOR] int n; }; s::s(int num) { n = num; …

Member Avatar for tux4life
0
118
Member Avatar for anilopo

It would be helpful to me if you posted the whole code (using code tags) you were trying to compile (if your question isn't already solved yet) ... Probably you forgot to type a ';' somewhere in your code :)

Member Avatar for anilopo
0
197
Member Avatar for dweller

If your whole class, including all your class' function declarations looks like this: [CODE] [COLOR="Green"]class A { int n; public: A::A(int num); void disp_num(); };[/COLOR] A::A(int num) { n = num; } void disp_num() { std::cout << "n = " << n << std::endl; } [/CODE] Then you'll have to …

Member Avatar for dweller
0
185
Member Avatar for cruisx

[QUOTE=amrith92;871565]If you had compiled this on a new compiler, then this would surely have thrown an error, wouldn't it?[/QUOTE] Nope, I can compile it using the newest MinGW compiler :) (BTW, If there's need for a Borland-style conio implementation for MinGW, you can always find it [URL="http://conio.sourceforge.net/"]here[/URL]) Regarding to the …

Member Avatar for amrith92
0
149
Member Avatar for m.s.sigdel

>Should I have to switch to other IDE? The IDE you're using doesn't define the programming language (C++), so the answer is no :)

Member Avatar for tux4life
0
100
Member Avatar for waldchr

Write and compile it as a Windows program (without a window), you could use the [ICODE]fstream[/ICODE] classes for file I/O :)

Member Avatar for waldchr
0
213
Member Avatar for Qousio

Can you please post your whole code? It's easier for me to find the error then :P

Member Avatar for ArkM
0
150
Member Avatar for skillincarnate
Member Avatar for Stinomus
0
362
Member Avatar for rizillion

[U]Example of a structure:[/U] [CODE] struct book { char title[25]; char author[25]; char publisher[25]; int price; }; [/CODE] [U] Example of an enum(eration):[/U] [CODE] enum book { BIG, SMALL, }; [/CODE]

Member Avatar for tux4life
0
204
Member Avatar for rizillion

The End.