6,741 Posted Topics

Member Avatar for YAMNA MIDHAT
Member Avatar for YAMNA MIDHAT
-5
4K
Member Avatar for fibbo

[QUOTE]When a vector is declared to have a certain number of things such as you init it to size(10000) it's very inefficient to init it with a for loop[/QUOTE] When the vector is already resized, using a loop to initialize is no different from using a loop to initialize an …

Member Avatar for fibbo
0
218
Member Avatar for UGndLord

[QUOTE]They don't bother teaching today's C/C++.[/QUOTE] That's not even today's C++. If they tried to teach today's C++, the teachers stuck in 1990 would have a stroke.

Member Avatar for Narue
0
3K
Member Avatar for sergent

[QUOTE=sergent;1633922]Why almost always capital letters are used when defining macros or variables like [CODE]#define SOMETHING 432[/CODE] instead of [CODE]#define something 3243[/CODE][/quote] Macros are problematic in that they're a preprocessor effect. History has shown that macros are both error prone and difficult to debug due to the text replacement of the …

Member Avatar for Narue
0
168
Member Avatar for Anuradha Mandal

[QUOTE]Then what it does?[/QUOTE] [ICODE]0<x<=2000[/ICODE] will be parsed as [ICODE](0 < x) <= 2000[/ICODE]. Or, depending on the value of x, either [ICODE]0 <= 2000[/ICODE] or [ICODE]1 <= 2000[/ICODE] since false and true evaluate to 0 and 1, respectively.

Member Avatar for Narue
0
122
Member Avatar for aloi93

Try restarting b at 1 for every iteration of the outer loop. And instead of one loop counting to 5, consider using two loops: one counting up to 3 and one counting down from 2.

Member Avatar for Anuradha Mandal
0
388
Member Avatar for BlackHawck

[QUOTE]compiled using Turbo c++ 3.0 compiler[/QUOTE] Have you considered dropping that ancient piece of shit and switching to a compiler that isn't twenty years old and severely limited under modern architectures? [QUOTE]it can't find the factorial of no. grater than six[/QUOTE] If this were true I would be confused, but …

Member Avatar for Anuradha Mandal
-1
752
Member Avatar for Hayzam Sherif

[QUOTE]This program is written in C++ not C.[/QUOTE] At a glance, I'd call that code C, and bet that it compiles just fine as C. It would also compile as C++, but if you're using a strict C-compatible subset of C++, quibbling over the code being C++ is kind of …

Member Avatar for Narue
0
211
Member Avatar for Digitalwolf

The standard library equivalent can be found in the <time.h> header (or <ctime> for C++). But being used to Java's Date and Calendar classes, you'll probably find the interface either quaint or woefully inadequate. p.s. I fairly recently posted a [URL="http://www.daniweb.com/software-development/cpp/code/335271"]code snippet[/URL] for for the beginnings of a date_time class …

Member Avatar for Digitalwolf
0
629
Member Avatar for pseudorandom21

[QUOTE=pseudorandom21;1633474]Do I Need to know assembly?[/QUOTE] While I'm an advocate of learning assembly, you don't need to know assembly to write a Windows driver. You might choose to use assembly at some point, in which case knowing it expands your options, but it's not a prerequisite.

Member Avatar for Narue
0
80
Member Avatar for D33wakar

Well, obviously strstr() alone won't do the job since it performs an unconditional exact match. You'll need to customize the behavior a little bit to suit your definition of a word: [code] #include <ctype.h> #include <stdbool.h> #include <stdio.h> #include <string.h> bool is_word(int ch) { return !isspace((unsigned char)ch) && ch != …

Member Avatar for Narue
0
231
Member Avatar for cplusplusrookie

In anticipation of questions like this, I wrote a [URL="http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx"]tutorial[/URL] on linked lists. The code is in C, but the concepts apply for any language.

Member Avatar for Narue
0
151
Member Avatar for SCass2010

Um, 20 bytes is well beyond the range of C++'s built-in types. I suspect you want an arbitrary length math library like [URL="http://gmplib.org/"]GMP[/URL].

Member Avatar for Duoas
0
1K
Member Avatar for h.senan

You have multiple problems with that code. Since I'm so nice, you can compare and contrast with the "corrected" code: [code] #include <ctype.h> #include <stdio.h> unsigned int get_int() { unsigned int c, sign; while (isspace(c = getc(stdin))) ; if(!isdigit(c) && c != EOF && c != '+' && c != …

Member Avatar for Narue
0
515
Member Avatar for evilguyme

[URL="http://www.boost.org/doc/libs/1_47_0/doc/html/boost_random.html"]Boost.Random[/URL] would be a good start. Just because rand() doesn't work for you doesn't mean you should write your own version that's better (you'd likely end up with something worse). There are many existing random number generators out there. [QUOTE]i have tried using rand() but i dont like it because …

Member Avatar for Narue
0
120
Member Avatar for kooletz

[QUOTE][CODE]scanf("%lf",a);[/CODE][/QUOTE] You're missing the address-of operator: [code] scanf("%lf", &a); [/code]

Member Avatar for gusano79
0
173
Member Avatar for KOFguru

clrscr() is a non-standard function typically declared in the <conio.h> header. Provided your compiler supports both <conio.h> [i]and[/i] clrscr(), including that header will fix your error. However, since your use of clrscr() is nonsensical anyway, my recommendation would be to remove it entirely (and change getch() to getchar()). In fact, …

Member Avatar for ashwin k v
0
213
Member Avatar for Ancient Dragon

I haven't had any problems with my iPad, though this sounds like a browser issue. Do you have any alternative browser applications? I'm not familiar with the Galaxy Tab.

Member Avatar for peter_budo
0
201
Member Avatar for ksm092
Member Avatar for ksm092
0
112
Member Avatar for TheProgramer

[URL="http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_sorting.aspx"]This[/URL] is a tutorial I wrote about sorting in C. It can easily be translated into C++, especially since you're using a a very C-centric subset of C++. Check out the insertion sort and merge sort sections for examples dealing with linked lists.

Member Avatar for Narue
0
220
Member Avatar for satish.paluvai

[B]Last Activity: Nov 26th, 2007[/B] The OP doesn't need help anymore.

Member Avatar for Narue
-1
270
Member Avatar for Hendo

The error is precisely as stated. The system() function expects an argument of type const char*, and std::string doesn't have an implicit conversion to that type. You need to call the c_str() member function: [code] system(drvPath.c_str()); [/code]

Member Avatar for Hendo
0
188
Member Avatar for dotancohen

[QUOTE]What is the significance of the letter n or l in these names?[/QUOTE] The "n" means that the operation is bound by a character limit, with the limit being remaining available space in the destination (in the case of strncpy() and strncat()), or a partial string count (in the case …

Member Avatar for dotancohen
0
131
Member Avatar for Mahesha999

It's a scanset. scanf() will look for characters between the brackets. A leading ^ acts as an exclusion modifier, so [ICODE]%[^\n][/ICODE] will look for anything that's not a newline and stop reading when it encounters a newline.

Member Avatar for Adak
0
147
Member Avatar for reza.adinata

[QUOTE]However, the goto statement is still executed[/QUOTE] The goto statement didn't execute. It only seems that way because your labeled statement is in both execution paths. Consider this: [code] #include <stdio.h> int main() { int a; a = 1+1; /* if (a!=2) { goto error; } */ error: printf("error is …

Member Avatar for reza.adinata
0
185
Member Avatar for ksm092

It works exactly as it should. You're passing month by value, so within renameMonths() "january" is being assigned to a copy. The original object in main() remains the same. To change the original object, you need to pass a reference (or a pointer): [code] void renameMonths(string& month) { if (month …

Member Avatar for Narue
0
251
Member Avatar for hqt

[QUOTE=hqt;1628555]but I don't know the different purpose of two type of declare: with above example is: [code] struct node** lastPtrRef=*Head;//type 1 struct node** lasPtrRef=&Head; //type 2 [/code] [/QUOTE] This is what I think your question boils down to, and the answer is that the first declaration is wrong while the …

Member Avatar for Narue
0
165
Member Avatar for theguitarist

[QUOTE]They say it is done in 2s complement form.[/QUOTE] There are several methods of representing signed values in binary. Two's complement is one of the more common on PCs. Others include one's complement and sign magnitude. [QUOTE]Now won't this 2s complement of a negative number clash with an actual +ve …

Member Avatar for Narue
0
163
Member Avatar for D33wakar

[QUOTE]Is there a way(builtin library functions,methods..etc.) to find the number of digits in the integer?[/QUOTE] Nope, you have to write that yourself. Though you can certainly use standard library functions to make it easier (log10() for example).

Member Avatar for TrustyTony
0
453
Member Avatar for GummyBear

How do you do it on paper? The parts where you find yourself repeating the same task will fall into a loop in code.

Member Avatar for GummyBear
0
150
Member Avatar for Bobbysmile

[QUOTE]error C2065: 'x' : undeclared identifier Simple as that. [/QUOTE] Yes, quite simple. You try to use x in printing() (via the USER_NAME macro), but x isn't declared in printing(). Macros are usable from the point of definition down (unless you #undef) and not bound by scope, so the effect …

Member Avatar for Bobbysmile
-1
501
Member Avatar for nuclear

[QUOTE]I tried using libs but some of them seemed to do all the work for me, the others seemed to be too complicated.[/QUOTE] How about writing your own version of those libraries? You might realize why doing all of the work for the programmer is a good thing, and/or why …

Member Avatar for nuclear
0
119
Member Avatar for rina khatkar

Okay, 'd' instead of 'the' I can understand (I don't agree with it, but I can understand), but WTF is up with omitting 'ee' from "between"? There's a point where being lazy and being a retard come together, and it's generally best to stay away from it when trying to …

Member Avatar for mrnutty
0
160
Member Avatar for rina khatkar
Member Avatar for Narue
0
63
Member Avatar for mullan123

So what other forums did you shotgun this question to aside from [URL="http://cboard.cprogramming.com/c-programming/140425-string-parsing-simple-shell.html"]here[/URL]?

Member Avatar for Narue
0
92
Member Avatar for Cap'nKirk

Each post has up and down arrows. When clicking on those arrows, you can choose to simply vote or give reputation.

Member Avatar for Cap'nKirk
0
37
Member Avatar for yakovm

[QUOTE]It does redirect but only from my main function.[/QUOTE] Is this other function coming from a DLL or something? Your described behavior suggests that the two functions are using different instances of stdout, or foo() is using some other method to write to standard output. You haven't provided enough information …

Member Avatar for Narue
0
97
Member Avatar for Simplified

The difference is subtle, but significant: [code] char cards1[] = "JQK"; // Array initialized with the contents of a string literal char* cards2 = "JQK"; // Pointer to a string literal object [/code] In cards1, you own the object, it's modifiable, and everything is hunky dory. In cards2, you own …

Member Avatar for Simplified
0
114
Member Avatar for I<3CPP

Your object is not a pointer, so there's no need to use the arrow operator. Also, the [] operator is already dereferencing your pointer, so there's no need for an explicit dereference either: [code] class myclass { public: int *ptrarray; myclass() { ptrarray = new int[2]; ptrarray[0] = 5; ptrarray[1] …

Member Avatar for I<3CPP
0
112
Member Avatar for bangor_boy

[QUOTE]if this system was expanded into a distributed environment the main issue I can for see is with so many people using the system then posts will go out off order[/QUOTE] Can you provide an example of this case? [QUOTE]so that only one user can have access to posting on …

Member Avatar for bangor_boy
0
146
Member Avatar for jonnyboy12

Well, since your first example is an prime example if dereferencing an uninitialized pointer, I'm tempted to suggest that you learn more about pointers. But I actually have a better answer to your immediate problem of not knowing when to use a pointer: don't use pointers. If you refrain from …

Member Avatar for mrnutty
0
112
Member Avatar for JustCC

First, beggers can't be choosers. You're not likely to end up doing what you're really interested in with an entry level job. The point of an entry level job is getting some practical experience, not landing your dream job. ;) Even if you want to do back-end stuff, it's smarter …

Member Avatar for Narue
0
236
Member Avatar for bd338

02h is a control character, not the numeric value of '2'. What you're looking for is 32h.

Member Avatar for bd338
0
302
Member Avatar for Prankmore
Member Avatar for Prankmore
0
201
Member Avatar for sathya88
Member Avatar for tubby123

[QUOTE]is there a way to replace a single characters by 2 characters in a string ????[/QUOTE] Yes, of course. [QUOTE]I answered linked list, I mean, take each node as a character, so u can easily insert 2 nodes, if u want to replace 2 characters.[/QUOTE] That's a very inefficient representation …

Member Avatar for Narue
0
123
Member Avatar for ChaseRLewis

Aren't you just a lucky duck. This feature is part of the new C++0x standard as variadic templates: [code] #include <iostream> #include <stdexcept> #include <string> template <typename ReturnType, typename... Args> class Function_Handler { typedef ReturnType (*fun_t)(Args...); protected: fun_t m_Function; public: Function_Handler(fun_t foo) { m_Function = foo; } Function_Handler() { m_Function …

Member Avatar for Narue
0
101
Member Avatar for eddie3377

[QUOTE]1. How did you become an IT Pro?[/QUOTE] Networking. I knew a guy who knew a guy who got me a chance to interview for a job. [QUOTE]2. Why did you become an IT Pro?[/QUOTE] I enjoyed being an IT amateur. [QUOTE]3. Do you love what you do?[/QUOTE] Yes. [QUOTE]Also, …

Member Avatar for PepperAdmi
0
235
Member Avatar for ialuvtimos

[QUOTE][CODE]s2[i]=s2[i]+s1[i];[/CODE][/QUOTE] What makes you think s2 is large enough to be indexed with s2[i]?

Member Avatar for Fbody
0
116
Member Avatar for Madawar

It's working as expected. The next character is '\n', so the loop terminates immediately. You never end your string with a '\0' character, and the program prints garbage.

Member Avatar for plebbeh
0
1K

The End.