6,741 Posted Topics

Member Avatar for gplkrsna

[B]>How can I resolve this issue??[/B] If you have control over the source for either library, simply change the name. If you don't have control, that's what I'd call a namespace nightmare. ;) One way to work around it is by using a wrapper library. The purpose of a wrapper …

Member Avatar for Narue
0
125
Member Avatar for kohkohkoh

>in c++? is the syntax the same or different? [code] #include <iostream> #include <string> using namespace std int main() { string name = "Derrick"; string filename = name + ".txt"; ofstream file ( filename.c_str() ); if ( file ) { file<< name <<endl; } } [/code]

Member Avatar for DoEds
0
129
Member Avatar for newcuser

[url]http://www.comeaucomputing.com/tryitout/[/url] Configure it to compile C89/90 or C99 and fix the errors. That should take you a [i]long[/i] way toward having pure C code.

Member Avatar for WaltP
0
171
Member Avatar for clutchkiller

[B]>Ive been googling everywhere, but havent really >found any examples on how to properly use it.[/B] I suspect what you found is what most of us would tell you: [code] for (string::size_type i = 0; i < s.size(); i++) s[i] = std::toupper((unsigned char)s[i]); [/code] You'll probably also find the broken: …

Member Avatar for Narue
0
398
Member Avatar for dista

[B]>how can this be taken care of? [/B] You have no choice but to allocate a new block of memory. Since str is a local array but needs a longer lifetime, you can replace it with dynamic memory: [code] char* foo (int ch) { char* str = malloc(10); if (!foo1(str, …

Member Avatar for Narue
-1
89
Member Avatar for merse

Are you sure that the literal character is using ASCII? [code] #include <iostream> #include <string> int main() { char a = 'รก'; char b = char(160); std::cout<< a <<" == "<< std::char_traits<char>().to_int_type(a) <<'\n'; std::cout<< b <<" == "<< std::char_traits<char>().to_int_type(b) <<'\n'; } [/code] My guess is that your text editor is …

Member Avatar for Narue
0
2K
Member Avatar for riotburn

Just because it compiles without errors doesn't mean the code works. Your I_simpson function is hanging, which means it doesn't return, which means you don't get any output.

Member Avatar for jazz_vill
0
420
Member Avatar for funtoknow
Member Avatar for pebbles
0
393
Member Avatar for LEEEEE

[QUOTE=vegaseat]Writing windows programs in C/C++ can be a bear for even experienced programmers. I started out with the DEV C++ package and quickly switched to BCX. This is a basic to C/C++ translator that uses simple basic code and allows inline asm and C code. If you are familiar with …

Member Avatar for WaltP
0
214
Member Avatar for problemkid

[B]>what are the advantages of a dummy head linked list and what is the implementation steps?[/B] [URL="http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx"]Click Me[/URL] [B]>how many linked list are there around[/B] Probably more than you can count, it's a very common data structure.

Member Avatar for Narue
0
109
Member Avatar for doddware

[B]>This is the first time I've ever seen this and I'm interested in any >reasoning why we shouldn't just remove it to eliminate code bloat.[/B] I can't claim to know what the original author was thinking, but I'm a fan of the double inversion for forcing an integer into a …

Member Avatar for Salem
0
185
Member Avatar for LitlAjah

[B]>If anyone can help with this.. I'd appreciate it![/B] This is a very simple algorithm that requires little more than common sense. Just pretend someone is handing you money and that you get to keep the smallest and largest bills. When you're done outlining the steps, turn the process into …

Member Avatar for mrnutty
0
102
Member Avatar for moods125

I'd say the error is a failure to pay attention. You use a different name for the index_of_next_smallest function when calling it, and neglected to declare indexPtr everywhere it's used

Member Avatar for Fbody
0
143
Member Avatar for aswin cp

This is just an extension of the largest value program. A super easy way to do it is two loops in succession. The first loop finds the largest value unconditionally, then the second loop finds the largest value excluding the result of the first loop: [code] max = first while …

Member Avatar for tintin.iitk
0
305
Member Avatar for COKEDUDE

[B]>How would I make all letters be an invalid input?[/B] I notice you don't check the return value of scanf. That's the first step in recognizing whether it failed or not. Then you can recover: [code] while (scanf("%f", &purchase) != 1) { /* This is me being lazy */ while …

Member Avatar for sumitunya
0
2K
Member Avatar for sonai4u

[B]>Will pay money for doing the assignment.[/B] No, cheater. Piss off. [B]>can u give me the codes...[/B] No, cheater. Piss off.

Member Avatar for Ancient Dragon
-7
498
Member Avatar for Kirielson

[B]>while (listPtr -> next != NULL) delete listPtr;[/B] Unless listPtr->next is NULL on the first iteration, you're deleting the same pointer multiple times. Try something more like this for the whole destructor: [code] while (listPtr != NULL) { NodePtr save = listPtr->next; delete listPtr; listPtr = save; } [/code]

Member Avatar for Kirielson
0
118
Member Avatar for suncica2222
Member Avatar for suncica2222
0
127
Member Avatar for CppBuilder2006

Grab a draft of the C++ standard (google is your friend) and search for "Temporary objects".

Member Avatar for CppBuilder2006
0
276
Member Avatar for darkagn

Do you keep track of who up or down votes, or is it a simple counter?

Member Avatar for Ancient Dragon
0
469
Member Avatar for Hawkpath

[B]>This website is complete with text and video tutorials made by my friend and I.[/B] As baby steps tutorials go, it's not the worst I've seen. However, from reading the tutorials, you don't strike me as being at a level where you should be teaching without a chaperone.

Member Avatar for Hawkpath
0
197
Member Avatar for Narue

Consider the following program and input file: [code] #include <algorithm> #include <cstdlib> #include <ctime> #include <functional> #include <fstream> #include <iostream> #include <iterator> #include <string> #include <vector> #include "natural_compare.h" struct natural_less: std::binary_function<std::string, std::string, bool> { bool operator()(const std::string& a, const std::string& b) { return natural_compare(a, b) < 0; } }; std::vector<std::string> …

Member Avatar for dusktreader
7
2K
Member Avatar for aya_brea

If you bothered to read the last week or so of posts then you would have seen that I gave a complete implementation for something like this. You could easily modify that or use it as a basis for your own implementation. But no, you wanted someone to do your …

Member Avatar for peter_budo
-3
2K
Member Avatar for corby
Member Avatar for wwsoft

It's not the namespace, it's the stuff in the namespace that gets redefined. Ideally you would put only declarations in a header and definitions in a separate implementation file. But you can help alleviate the problem with [URL="http://en.wikipedia.org/wiki/Include_guard"]inclusion guards[/URL].

Member Avatar for wwsoft
0
145
Member Avatar for dragontruong
Member Avatar for dragontruong
0
111
Member Avatar for daveoffy

Works for me: [code] #include <stdio.h> #include <time.h> int main(void) { time_t t = time(NULL); struct tm *now = localtime(&t); printf("Day of the year: %d\n", now->tm_yday); return 0; } [/code] Output (for Feb 15th, 2010, EST): [code] Day of the year: 45 [/code] What was your "incorrect number"?

Member Avatar for daveoffy
0
190
Member Avatar for JHus00

[B]>else if (weight >= 100 & < 200)[/B] "else if weight is greater than or equal to 100 and less than 200". That makes perfect sense, but it's wrong. C++ won't infer that in the second half of the expression you're still trying to compare with weight. Further, & is …

Member Avatar for JHus00
0
114
Member Avatar for suta6

[B]>ans is -2201 how? >please explain the ans >please explain[/B] Why don't you start a new thread instead of hijacking an old one, then try to explain it yourself and we'll make corrections. We're not here to do your homework. p.s. Bumping the thread with the same question after a …

Member Avatar for WaltP
-2
90
Member Avatar for ankara84

Why don't you just tell us your teacher's email address so that we can send the program directly?

Member Avatar for Nick Evan
0
2K
Member Avatar for CollegeBound

Sounds like homework questions. How about you come up with at least one reasonable answer to each and we'll tell you if they make sense and possibly offer more.

Member Avatar for CollegeBound
-1
116
Member Avatar for daveoffy
Member Avatar for Narue

Regular: A Daniweb member who visits/posts frequently, and tends to be friends with others who visit/post frequently. New members could easily be overwhelmed by the mass of people running around, and it's hard to fit yourself in a community as old as Daniweb, where members are already well entrenched and …

Member Avatar for jonsca
2
512
Member Avatar for burkeyb
Member Avatar for cthreash

1) No, the lifetime of a string literal is equal to that of the program. 2) Yes, the address you're saving is still that of the string literal. 3) You're pointing to a string literal, so it's all good. However, note that identical string literals may share memory, so you …

Member Avatar for cthreash
0
391
Member Avatar for shankhs

[B]>There are a lot of programs that do not require GUI, console, or human interaction.[/B] Sadly, there's a misconception (especially among beginners) that GUI programming is the "next step" toward being a real programmer. :icon_rolleyes:

Member Avatar for tkud
0
626
Member Avatar for johndoe444

[B]>Why the output is 100?[/B] var + 12 = var12. [ICODE]printf("%d", var12)[/ICODE] prints the value of var12, and var12 was initialized to 100.

Member Avatar for Narue
0
138
Member Avatar for invisi

[B]>Try it like this[/B] The size of the first dimension of an array parameter isn't required, but you can put it there and it'll be ignored. The two lines of code you posted are functionally identical.

Member Avatar for invisi
0
100
Member Avatar for shailev

[B]>How can i do this??[/B] Did you start by searching? Converting an integer to a string is a very common question.

Member Avatar for Salem
0
80
Member Avatar for latszer

[B]>fgets(usercheck,256,stdin);[/B] Don't forget to check for failure. The last thing you want to do is dereference a null pointer on the next line. [B]>usercheck[strlen(usercheck) - 1] = '\0';[/B] While this covers the average case, it's possible for fgets to succeed yet not end with a newline. Unless you want an …

Member Avatar for Narue
1
221
Member Avatar for elton571

We can read you know. You don't have to capitalize the "important" words for us. :icon_rolleyes:

Member Avatar for Narue
-1
60
Member Avatar for hsp700

[B]>(1) "(when we insert one character)Why code prints "10" >after printing ascii value of the character we insert?" [/B] Because you actually typed two characters? You press the 'a' key right? Then you press then [Enter] key, right? That's two characters: 'a' and newline. I'd love to hear why you …

Member Avatar for hsp700
0
132
Member Avatar for invisi

[B]>There are no known sorting algorithms that perform in linear time.[/B] There are no known [I]comparison-based[/I] sorting algorithms because the limit with a comparison tree is Omega(nlogn). But linear algorithms do exist using other methods, such as distribution.

Member Avatar for Narue
0
127
Member Avatar for BarakH

[B]>Am I right? wrong? missing something?[/B] That's a toughie. While a compiler [i]might[/i] inline your function, it's best to assume that there will be overhead. However, the overhead of a function call isn't exactly significant these days, which is why it's generally better to modularize (your teacher's suggestion) than to …

Member Avatar for tetron
1
111
Member Avatar for Fbody

[B]>If you shift more than 31-bits left[/B] The behavior is undefined. [B]>The issue is the fact that 32-64=-32 which on a right shift operation is 32-bits left.[/B] No, that's undefined too. If you shift in either direction by a negative value or by a value greater than or equal to …

Member Avatar for Fbody
0
164
Member Avatar for tzushky

[QUOTE=gerard4143;1128999]I know this is knit picking... [QUOTE]We all know that we can use the name of an array as the pointer to that array,[/QUOTE] The name of an array is a label which is a convenient human readable memory address. Its not a pointer...[/QUOTE] Actually, the statement you quoted is …

Member Avatar for Narue
0
3K
Member Avatar for traced

I can think of two super easy ways to do it: [LIST=1] [*]Use a second array and copy the parts that aren't deleted. All you need to do is find the start of the substring you want to delete and it's a matter of calling strcpy. [*]Shift all contents of …

Member Avatar for WaltP
0
106
Member Avatar for zangetsuu

[B]>zangetsuu[/B] I can't decide if you like Bleach but only watched the English dub, or zangetsu was taken and you just added an extra 'u' to the end. If it's the former, the name Zangetsu is pronounced something like "[I]Zahn[/I]gets". The "oo" sound at the end is virtually silent when …

Member Avatar for zangetsuu
0
127
Member Avatar for mrnutty

[B]>This is a little hard for me to believe.[/B] It really depends on the job. I've done interviews in other fields where that's a fairly accurate statement, assuming "can't write code at all" is stated more along the lines of "can't do much beyond 'hello world'". We can blame the …

Member Avatar for vaultdweller123
0
1K
Member Avatar for liljazz2007

[B]>This is my 1st time hearing about SRC Code and my teacher isnt being a big help.[/B] Presumably you learned about SRC assembly in class, otherwise your teacher wouldn't give the assignment. The link doesn't work, so I can't see your assignment. Perhaps if you gave some more details on …

Member Avatar for Nick Evan
0
243

The End.