6,741 Posted Topics

Member Avatar for DJPlayer

The specifier for double with scanf is %lf. %f is for float. Also note that we have a separate forum for C++ questions. This is the C forum.

Member Avatar for Narue
0
156
Member Avatar for furqankhyraj

I want you to ask a [URL="http://catb.org/~esr/faqs/smart-questions.html"]smart question[/URL], but apparently neither of us are getting what we want.

Member Avatar for WaltP
0
150
Member Avatar for hemant_is_here

>plz explain me with syntax "how to pass pointer to a function or pointers to a function " For each level of indirection in the function argument list, add an asterisk. If the argument isn't already a pointer of the same type as the argument list, dereference or add & …

Member Avatar for jamma
0
804
Member Avatar for Zaelis

[B]>Should I be using fget instead of scanf?[/B] Yes: [code] if ( fgets ( input, sizeof input, stdin ) == NULL ) { /* Handle input error */ } [/code] [B]>scanf( "%c\n", &input[81] );[/B] For the record, input[81] is an invalid index because the size of your array is 81. …

Member Avatar for erantivanisha
0
144
Member Avatar for saracooper

[B]>tempStr[0] = va_arg(arg_ptr, char **);[/B] A two dimensional array is not compatible with a pointer to a pointer. Either switch to using an actual pointer to a pointer for your source, or pull the correct type from your varargs list: [code] #include <stdio.h> #include <stdarg.h> #include <string.h> #include <stdlib.h> void …

Member Avatar for saracooper
0
2K
Member Avatar for suncica2222

[B]>So if you return -1 its gonna throw exception or what?[/B] -1 is a valid return value, but what it means is implementation-defined. [B]>how is perfectlly normal in java to say public static void main( String args[]) {} ???????[/B] When you design a programming language, you make the rules. It's …

Member Avatar for Narue
0
85
Member Avatar for Vhalor

Here's one way with sscanf: [code] #include <stdio.h> int main(void) { const char *src = "-6 1 2 3 6"; int pos = 0; int n = 0; int x; while (sscanf(src + pos, "%d%n", &x, &n) == 1) { printf("%d\n", x); pos += n; } return 0; } [/code]

Member Avatar for Narue
0
124
Member Avatar for NjNetsFan1

[B]>i need to print them out ascending and descending[/B] To sort descending, it's a simple matter of reversing the comparison in your bubble sort function. You can either write a second function, or modify your current one to use a flag passed in as a parameter: [code] void Bubblesort (char …

Member Avatar for NjNetsFan1
0
141
Member Avatar for timbomo

[B]>cin >> length, width;[/B] This doesn't do what you think. A comma is inapproriate, it should be another >> operator: [code] cin>> length >> width; [/code] [B]>cout << " The total cost will be " << areaR << endl; >areaR= (length * width); >cin >> areaR; >cin >> areaR;[/B] This …

Member Avatar for Narue
0
106
Member Avatar for WargRider

[B]>I REALLY badly need something of that kind[/B] Perhaps if you describe what you're trying to do, one of us can suggest a solution better suited to C++.

Member Avatar for Narue
0
4K
Member Avatar for timbomo

The only things [icode]int[/icode] can hold are whole numbers. Any precision you assign to an integer will be truncated.

Member Avatar for WaltP
0
85
Member Avatar for Jeronim

[URL="http://www.cplusplus.com/reference/algorithm/"]C++ reference: <algorithm>[/URL]. The generate and fill families are probably what you want. You can also use the inherited C functions in some cases, but for C++ they're more likely to be dangerous than anything.

Member Avatar for Narue
0
78
Member Avatar for JohnPhilipps

Your compiler is right: [B]>data[i] != '\0'[/B] Data is an array of System::String. '\0' is a character literal. I'm not sure what you were trying to do here (perhaps compare data[i] to nullptr?), but you could just as easily use the Length property of the managed array type: [code] for …

Member Avatar for JohnPhilipps
0
189
Member Avatar for glenc70

Since you don't know how many objects there will be, a dynamically sized collection is probably the way to go: [code] #include <ctime> #include <ios> #include <iostream> #include <limits> #include <string> #include <vector> int main() { std::vector<std::string> v; char ch; while (std::cin.get(ch)) { std::time_t now = time(0); v.push_back(std::ctime(&now)); if (ch …

Member Avatar for Narue
0
98
Member Avatar for jesoj

[B]>fnptr =this->myvurtualfn1(); //error C2440: '=' : cannot convert from 'void' to 'void (__cdecl *)(void)'[/B] [LIST=1] [*]You're not taking the address of the member function, you're calling it. [*]Pointers to member functions are not compatible with pointers to functions. [/LIST] [URL="http://www.eternallyconfuzzled.com/tuts/languages/jsw_tut_pointers.aspx#ptrtype"]This[/URL] might help with the syntax issues.

Member Avatar for jesoj
0
1K
Member Avatar for jesoj

Aside from having everything initialized/destroyed for you by the compiler, and hiding the actual dereferencing through convenient syntax, there's really no magic to the vtable method of polymorphism. Just out of curiosity, why are you doing something manually that C++ already supports?

Member Avatar for Salem
0
225
Member Avatar for cecilia_g1

buffer[i] es un número entero. No es necesario diferenciar entre decimal y hexadecimal que se imprima el valor: [I]buffer[noparse][i][/noparse] is an integer. You don't need to differentiate between decimal and hexadecimal until the value is printed:[/I] [code] buffer[i] = atoi ( aux ); /* La única diferencia es cómo buffer …

Member Avatar for Narue
0
138
Member Avatar for vmanes
Member Avatar for ddanbe
1
334
Member Avatar for shrublet

[B]>As it stands now, I am getting a segfault.[/B] I'm not surprised. You have the right idea in making a copy of the name to return, but you're attempting to return a pointer to a local variable, which is a bad idea. When a function returns, the local variables are …

Member Avatar for rajdesire
0
114
Member Avatar for Ed Ashworth

[B]>Recently I replaced the 6.0 with Visual C++ 2008 Express. >Now, none of my older code will compile.[/B] I'm not surprised. One of the biggest things Visual C++ 6 supports that newer versions do not is the prestandard headers: [code] // Compiles in VC++6, but not VC++2008 #include <iostream.h> int …

Member Avatar for jonsca
0
141
Member Avatar for hydersha

[B]>please help how can i do this[/B] Two easy ways: [list=1] [*]Throw all of the numbers into a better suited data structure (such as an std::map). [*]Sort the array and do some counting. [/list]

Member Avatar for jonsca
0
853
Member Avatar for vader1231231

[B]>I just kinda fiddled with different combinations till I got it to work.[/B] That's called programming by accident, and it means you're no better than an ape pounding at the keyboard. There's no design involved, you run an even higher risk of introducing bugs into code you don't understand, it's …

Member Avatar for Narue
0
59
Member Avatar for n.utiu

[B]>Dev is quite a good compiler and editor but IMO the debugger...sucks.[/B] Yes, the debugger in Dev-C++ has a bit to be desired. It's actually just a graphical interface into gdb, and not a very good one. [B]>So I would like to know your opinion on Dev[/B] I like it, …

Member Avatar for abdelhakeem
0
91
Member Avatar for mmasny

[B]>If so, how do I write this constant address?[/B] Cast it to the appropriate pointer type: [code] int *p = (int*)1; [/code] However, it's strongly recommended that you [i]don't[/i] do this unless you really know what you're doing.

Member Avatar for Salem
0
100
Member Avatar for mo94015

[B]>need to change this from availcredit01.cpp to availseats01.cpp >and make the necessary adjustments[/B] Well? What have you done to accomplish this requirement, what's the problem that prompted you to post a thread, and how did you attempt to fix the problem before running to us with your tail between your …

Member Avatar for Narue
0
97
Member Avatar for timbomo

If you have a question about a specific error, post the error message. If you want to post code, use code tags. [B]>what is a better way too write this without getting an error[/B] Well, seeing as how your syntax is horribly broken, I'd say start by cracking a book …

Member Avatar for Narue
-1
180
Member Avatar for SpyrosMet

Do you know how to pass an array of pointers to int? It's the same thing, just with a different pointer type: [code] void duh ( int *array[], size_t size ); [/code]

Member Avatar for Narue
0
190
Member Avatar for sidra 100

[B]>now chk wats wong at line 26 and 34[/B] The same thing that was wrong before: you're trying to write code too far beyond your ability. Start smaller and work your way up. At least then you won't have to rely on other people to hold your hand the whole …

Member Avatar for sidra 100
0
123
Member Avatar for Whilliam

Um, there's more to a trie than that. Have you worked with binary search trees before? Tries are a more general tree structure where the number of nodes isn't restricted.

Member Avatar for abhimanipal
0
75
Member Avatar for b.bob

[B]>This library is powerful, helpful, and relatively easy >to learn, and it works in all c++ compilers.[/B] Visual C++ 6 has a notoriously broken standard library (especially the STL). But with a few caveats, you're right: [LIST=1] [*]Compilers that were released before or around 1998 may not conform well at …

Member Avatar for dusktreader
0
382
Member Avatar for swathydoss
Member Avatar for vicsta

[B]>I suppose you're looking for something like that if i am not mistaken[/B] I can't tell if you're incompetent or simply posting bad code to get the OP a failing grade.

Member Avatar for Narue
-1
105
Member Avatar for Suraine

[B]>Sorry to harsh, but ...well...you know... it sucks.[/B] It could always be worse. For example, he could be using a variable length array extension instead of [ICODE]new[][/ICODE].

Member Avatar for WaltP
0
10K
Member Avatar for dondajr

Look up the escape characters for C. You have the option of an octal escape character and a hexadecimal escape character.

Member Avatar for dondajr
0
287
Member Avatar for kppowell

>iostream is somewhat more restrictive than the older iostream.h. If by "more restrictive" you mean the requirement to qualify the std namespace when using a standard name. iostream is vastly more powerful and flexible than iostream.h and is more fully featured. >iostream.h is deprecated No, iostream.h is [b]gone[/b]. It was …

Member Avatar for sonu babu
0
280
Member Avatar for atticusr5

[B]>assign6.cpp:110: error: ‘accountID’ was not declared in this scope[/B] Your compiler is right, accountID was never declared in the cAccountList::sort_by_ID member function. You need to declare a variable before using it. [B]>assign6.cpp:111: error: ‘class cAccount’ has no member named ‘get_accoutID’[/B] Check your spelling. [B]>assign6.cpp:112: error: no match for ‘operator<’ in …

Member Avatar for Narue
0
143
Member Avatar for sadhramani
Member Avatar for Aiyen

[B]>while(i < N - k) PartSum +=DataArray[i];[/B] [ICODE]i[/ICODE] is never updated in this loop.

Member Avatar for Aiyen
0
94
Member Avatar for abhimanipal

[B]>Is there any standard rules when we write the main function.[/B] Oddly enough, there are. You have two 100% portable definitions of main: [code] int main ( void ) { /* ... */ } [/code] [code] int main ( int argc, char *argv[] ) { /* ... */ } [/code] …

Member Avatar for Narue
0
243
Member Avatar for Stefano Mtangoo

[B]>So what do you love to use when it come to C/C++?[/B] I think love is a strong word for a tool. I like various features of the different IDEs I use, and choose among them based on my needs (if I choose to use an IDE at all). Visual …

Member Avatar for VilePlecenta
0
232
Member Avatar for VilePlecenta

[B]>Q1: Should I continue studying this even though it could be a bit outdated?[/B] Yes, the Win32 API is still relevant. But be sure to use [URL="http://msdn.microsoft.com/en-us/library/default.aspx"]MSDN[/URL] to keep yourself up-to-date on the latest additions, because as you said, that book [I]is[/I] somewhat old. [B]>Q2: What is the best most …

Member Avatar for VilePlecenta
0
330
Member Avatar for wwsoft

You can supply a predicate to the [URL="http://www.dinkumware.com/manuals/default.aspx?manual=compleat&page=algorith.html#sort"]sort[/URL] template from <algorithm> that does the comparison: [code] #include <algorithm> #include <vector> void sort_object_list ( std::vector<sometype>& object_list ) { struct compare { bool operator() ( const sometype& a, const sometype& b ) { return a.z < b.z; } }; std::sort ( object_list.begin(), …

Member Avatar for wwsoft
0
107
Member Avatar for cpu-guy

[B]>Do anyone knows how we can implement this code[/B] Yes. [B]>I need a help quickly.[/B] We're not a charity for lazy students. If you want help, you need to do some work yourself first.

Member Avatar for cpu-guy
0
143
Member Avatar for NickRx

[B]>using namespace std;[/B] You can remove this line by explicitly qualifying the std namespace on your names. [B]>cin.clear (); >cin.get (); >cout << endl;[/B] These lines are unnecessary. Further, you can merge the input into a single prompt: [code] std::cout<<"Enter two numbers: "; std::cin>> a >> b; [/code] [B]>cout << …

Member Avatar for Narue
0
159
Member Avatar for rwill357

[B]>Will this function accomplish that?[/B] Oh, dear. [B]>tmp = (IntSLLNode*)malloc(sizeof(IntSLLNode));[/B] Why are you allocating memory? This function [i]deletes[/i] nodes. [B]>tmp = head;[/B] Bye bye memory. Now you've lost your only pointer to the memory you just allocated. That's what we call a memory leak. [B]>oldTmp = (IntSLLNode*)malloc(sizeof(IntSLLNode)); >oldTmp = tmp;[/B] …

Member Avatar for Lerner
0
395
Member Avatar for chieny

[B]>just wanted to learn more.[/B] You might consider learning things that have a chance of being used outside of a classroom setting. Turbo C is pretty much dead except in out-of-date schools and historically interested hobbyists.

Member Avatar for Narue
-2
56
Member Avatar for b1izzard

[B]Q: what are the different stages in SDLC? Me: Requirement Analysis -> Design -> coding -> Testing -> Implementation and Maintenance[/B] Canned answer to a vague question, not promising at all. I'd expect you to dig for more details before coming up with an answer. For example, which methodology am …

Member Avatar for happygeek
0
301
Member Avatar for gingerx

How do you know it can't open the file? Does your error message print? If so, change it to this for more details: [code] perror ( "Error: file could not be opened" ); [/code]

Member Avatar for gingerx
0
1K
Member Avatar for nerdinator

[B]>MultiThreading?[/B] Multithreading, spawn multiple processes, or fake your own threading. The latter isn't recommended for real code, but it can be fun. [B]>Please type the code for this,if you can.[/B] I'm not going to do your work for you, dude. You didn't even say what platform you're running on, which …

Member Avatar for nerdinator
0
95
Member Avatar for blue:

ofstream opens the file in write mode, which truncates any existing data. You can specify [ICODE]ios::app[/ICODE] as the second argument to ofstream's constructor. This will append without truncating. p.s. I'm not in the mood to beat some sense into you, so I'll let everyone else snipe at your code and …

Member Avatar for blue:
0
117

The End.