6,741 Posted Topics

Member Avatar for Sh13

You can traverse a two-dimensional array with a nested loop: [code] for ( i = 0; i < 10; i++ ) { for ( j = 0; j < 10; j++ ) printf ( "%c ", array[i][j] ); } [/code] >Second, that how would i put character 'A' in location …

Member Avatar for Aia
0
305
Member Avatar for #include_rose

>I'm having some trouble understanding the advantages >and disadvantages of using scanf over fgets. I imagine because the comparison is difficult. scanf and fgets do different things. scanf is designed for formatted input and fgets is designed for unformatted input. >But in what way does fgets prevent that from happening? …

Member Avatar for #include_rose
1
754
Member Avatar for tracethepath

>bt i dont hv >using namespace std; >at d beginning... If you're not using namespaces or getting compilation errors then you're not learning standard C++. I'd wager your teacher is teaching you C++ on his favorite compiler, which happens to be old as dirt. >at d beginning...i olwayz write progam …

Member Avatar for Narue
0
2K
Member Avatar for gator6688

You already have a counter, so just print that value instead of something hard coded: [code] cout << "Person #" << i + 1 << ": "; [/code]

Member Avatar for WaltP
0
96
Member Avatar for gator6688

>What am I doing wrong? twomers already showed you. 1,2,3,4 isn't a list of values, it's four expressions separated by the comma operator. The result is most certainly not what you expected. Here's what actually happens: PeopleTypes[i] != 1 is tested. If PeopleTypes[i] is actually 1, the expression is false, …

Member Avatar for WaltP
0
103
Member Avatar for restrooms

Your code is riddled with syntax errors. So many, in fact, that it's not even worth my time to point them out for you. I recommend you scrap your code and start over, but this time, pay close attention to what you're doing (programming requires an eye for detail) and …

Member Avatar for WaltP
0
138
Member Avatar for DemonSpeeding

>I read up on switches, and it says they're used for strings, not chars Quite the contrary. A switch doesn't work with strings, but because char is an integral type, it works just fine as a switch case.

Member Avatar for DemonSpeeding
0
202
Member Avatar for cms271828

>Can anyone recommend a good IDE to get started with, and how I can set up. Visual C++ Express is good, and it's easy to install. Dev-C++ is also good and easy to work with, but it's kind of a dead project. I've been hearing good things about Code::Blocks, but …

Member Avatar for Duoas
0
143
Member Avatar for redaqen
Member Avatar for cl3m0ns

>I would like to display the highest randomly generated number in the equation. How is that trickier? Keep a running maximum (like the sum in your average algorithm) as you walk through the array. When you see a value that's larger than the maximum, it becomes the new maximum: [code] …

Member Avatar for cl3m0ns
0
95
Member Avatar for wonderland

>is it possible to input unlimited amount of nummbers nut just number 1 + number 2? Yes. You need a running sum, a count of how many numbers there are, and one variable for the number. Then you'd do this: [code] int count = 0; int sum = 0; int …

Member Avatar for wonderland
0
181
Member Avatar for cl3m0ns

Add them to a sum using a loop, then divide by 30. That's generally how one would find the average of a list of numbers: [code] double sum = 0; for ( int i = 0; i < 30; i++ ) sum += a[i]; cout<<"Average: "<< sum / 30 <<'\n'; …

Member Avatar for cl3m0ns
0
93
Member Avatar for fastfred

>Is this encoding designed to hide the programming? Compiled programs aren't like HTML. The source code is lost during compilation unless the executable format supports metadata that can reconstruct it, like .NET. Those symbols you saw were the text editor's attempt to turn binary into printable characters. >How can I …

Member Avatar for Narue
0
5K
Member Avatar for HLA91

>//Yes I did put in 'return 0' because it's bad >//practice to leave it out and yada yada yada... You're not getting away with this one. :) Explain why it's a bad practice, please.

Member Avatar for Narue
0
180
Member Avatar for csteverun

Your declaration is off. It declares pointer_to_array_of_atype to be an array of pointers to aType, not a pointer to an array. To get a pointer to an array, you wrap the asterisk and identifier in parens. But also keep in mind that the array sizes should match: [code] aType (*pointer_to_array_of_atype)[5]; …

Member Avatar for csteverun
0
97
Member Avatar for nano404

>I'm having some problems with creating user defined functions. A function definition has four parts: the return type, the function name, the parameter list, and the body. It looks like this: [code] <return type> <function name> ( <parameter list> ) { <body> } [/code] This declares and defines a function. …

Member Avatar for nano404
0
128
Member Avatar for sugarflaps

Wow. Scary. The first two errors you're getting come from the fact that you can't use a variable if you haven't declared it first. num_rows and num_colms don't exist in main. The next error is because your syntax is completely screwed up. None of the braces match, there are extra …

Member Avatar for Narue
0
70
Member Avatar for Duki

>Am I wrong? Yes, they're different in pretty much every way due to the differing syntax and semantics of scalars and arrays. You can't even say that they have the same storage costs because arrays are allowed to use extra space before and after the accessible items.

Member Avatar for Narue
0
116
Member Avatar for Exsiss

>if ( i >= 'LetterToMatch') I'm going to go out on a limb and guess that you meant: [code] if ( i == LetterToMatch ) [/code] LetterToMatch is a variable, and you're checking to see if i matches it, correct? Also, if you're going to test against LetterToMatch, you need …

Member Avatar for Narue
0
316
Member Avatar for anirudhbsg

It sounds like you aren't actually linking with the library when you build your program. Why don't you describe exactly how you're compiling and linking the program? Oh, also mention your OS and compiler.

Member Avatar for Salem
0
85
Member Avatar for skyah

>void transpo_sort(int a[], int i); This doesn't call the transpo_sort function, it declares the transpo_sort function. In other words, absolutely nothing is happening to your array. >printf("After Pass #2:%7d,%5d,%5d,%5d,%5d,%5d,%5d,%5d \n", a[i],a[i],a[i],a[i],a[i],a[i],a[i],a[i]); i is 0, and a[0] is 7. It's no surprise that printing a[i] eight times gives you eight 7's.

Member Avatar for ithelp
0
92
Member Avatar for DemonSpeeding

>What about if someone wanted to add something to the beginning or somewhere between? It's more or less the same deal. You move everything from the index you want to add to, to the end of the array forward by one element. Then you add the new value to the …

Member Avatar for Ancient Dragon
0
105
Member Avatar for beatlea

You can use the %n conversion specifier to find out how many characters were read and adjust the source string accordingly: [code] #include <stdio.h> int main( void ) { const char *src = "this is a test"; char word[5]; int n; while ( sscanf ( src, "%4s%n", word, &n ) …

Member Avatar for Salem
0
3K
Member Avatar for skyah

>Here's the solution: Great. Now the OP has learned absolutely nothing from this exercise. I hope you end up working with someone who breezed through school without having to learn, because then you'll realize why giving away the entire solution like that hurts more than it could possibly help.

Member Avatar for Narue
0
214
Member Avatar for sylvaticus

>I would avoid of load the whole file in memory and then printing it line-by-line.. Read a line, process it, and write it to a temporary file. Then delete the original file and rename the temporary. >is it possible ?? It's hard to say. You talk about appending to a …

Member Avatar for Narue
0
108
Member Avatar for locy
Member Avatar for locy
0
243
Member Avatar for k7_keshav

Not until you tell us what your compiler and OS are. Standard C++ doesn't know jack about a mouse or click options.

Member Avatar for GreenDay2001
0
94
Member Avatar for tnvkrishna
Member Avatar for near

>i need help here(urgent!!) First thing's first, urgent for you doesn't mean urgent for us. Deal with it. >gets (string); Don't ever use gets. It's evil, and there's no way to make it less evil. Use fgets instead. Your count isn't counting the right thing. You're counting the number of …

Member Avatar for near
0
226
Member Avatar for zandiago

>I've completed programs with the use of the getline function and it works ok. I bet those programs didn't try to pass a double into getline instead of a string: [code] double number;//the grades as in the infile while (getline(infile,[COLOR="Red"]number[/COLOR],'\n') [/code] There are other problems too: >int num;//number of grades …

Member Avatar for zandiago
0
564
Member Avatar for notathing

Nobody will write it for you. If you're not willing to do it yourself, we're not even willing to help you a little bit.

Member Avatar for twomers
0
87
Member Avatar for sean25hun

>I got it to do a factorial number , now it want to display the results in a pyramid Do you understand how to use factorials to derive an individual number from the pyramid?

Member Avatar for Narue
0
191
Member Avatar for restrooms

>can someone tell me if the code is right. No, it's not right. >#include<conio.h> I can't stand programs that abuse conio.h. You don't need it, so why use it? >int num1,num2,num3; >int num4,num5; There's exactly zero reason for using global variables. >printf("ENTER NUMBER"); Unless you print a newline after the …

Member Avatar for hopalongcassidy
0
100
Member Avatar for DemonFox

Those errors have more to do with not knowing how to use a class than not understanding trees. Because those functions are member functions, you need an object of the tree class before you can call them.

Member Avatar for eskelsen
0
114
Member Avatar for locy

>for(int i=0; i<10; i++) /* Not proper C syntax */ Not proper C89 syntax. C99 supports this feature.

Member Avatar for Lardmeister
0
149
Member Avatar for bluejay_1111

>Most of it is done Not really. What you want to do is actually pretty involved if you want to do it right. If you want to keep it relatively simple, make the functions that work with a wordInfo object into member functions. Then from the definition of those functions, …

Member Avatar for bluejay_1111
0
186
Member Avatar for jaepi

fseek64 isn't a standard function, so if it exists for your compiler, the documentation will tell you where to find it and how to use it. Have you tried fgetpos and fsetpos? They're designed for large files and the implementation typically uses a 64-bit type as the base for fpos_t. …

Member Avatar for jaepi
0
1K
Member Avatar for slyrexy

>i have looked all though my textbook and all over the >net and have not found any examples similar. You mean you haven't found any examples that do exactly what you want. I find it hard to believe that there are no examples that are similar, because I've written a …

Member Avatar for slyrexy
0
85
Member Avatar for jenymaru08

If string.h isn't allowed, I'm reasonably sure std::string isn't either. This is my educated guess based on the fact that the OP is using an old compiler that probably doesn't support std::string. :icon_rolleyes:

Member Avatar for ChaseVoid
-1
140
Member Avatar for Llama

>SRL 3.81 to SRL 4.exe has encountered a problem and needs to close. Classic runtime error. It means you're probably overrunning a buffer somewhere. Run your program in debug mode and step through it until you hit the error. That'll give you a good idea of where the error is …

Member Avatar for Llama
0
241
Member Avatar for locy
Member Avatar for akame

>well it is better if u can give straight 4wd answers... Salem's answer not only was as thorough as possible given the complete lack of information you provided, it was also useful in other ways. So drop the attitude.

Member Avatar for Salem
0
132
Member Avatar for gallantmon1

>I usually fix the errors first before I fix the appearance of the code. The appearance of the code helps you find errors, genius.

Member Avatar for gallantmon1
0
249
Member Avatar for alex_bhes14

>everyone here can give me the code of this sample program.. No, everyone here can tell you to do your own homework. We'll help you with it, but we won't do it all for you. Sheesh.

Member Avatar for Narue
0
46
Member Avatar for gallantmon1

As much as I love trees, I'm not keen on deciphering your code and then figuring out where you're lost. So I'll ask you to be more specific about what you want help with, and show you the structure code I use myself: [code] void jsw_structure_r ( struct jsw_node *root, …

Member Avatar for Narue
0
149
Member Avatar for pacman326@gmail

[code] for(int i= 0; i < 15; i++) { int column = 0; for(int i= 0; i < 12; i++) { gameBoard[i][column] = rand() % 9 + 1; } cout << endl; column++; } [/code] I'm not sure what you think this is doing, but it's not filling the table …

Member Avatar for Narue
0
81
Member Avatar for locy

Do you want us to install it and configure it for you too? Ooh, and should we use it to write all of your programs as well? Why don't you pick out a compiler first, then try to install it yourself. Then if you have problems, we can probably help. …

Member Avatar for dwks
0
148
Member Avatar for jrice528

>I need the function flip() to return the value of heads and tails back into main, without using any arguments. Why can't you use arguments? Functions can only return one value. Unless you put the heads and tails into some sort of aggregate type, or pack them both into a …

Member Avatar for iamthwee
0
180
Member Avatar for frozenflame2

>Using this would be better practice b=b-'a'+'A'; Since its not >necessary that you use ASCII character encoding always. You're splitting hairs when there's no difference at all. Both solutions are non-portable and rely on the setup of the ASCII character set. The latter is a better choice [I]only[/I] because it …

Member Avatar for Narue
0
116
Member Avatar for toko

>how?? Probably with string input. With over 20 posts, you should be aware of how we expect the Q&A process to work. You're a part of the process, which means we're not just going to tell you how to do things. You have to think about it yourself and show …

Member Avatar for Narue
0
69

The End.