6,741 Posted Topics

Member Avatar for Prankmore

So much time wasted for such a simple task. I wonder if the OP really wants to do it and isn't just looking for a handout.

Member Avatar for Prankmore
0
3K
Member Avatar for Kalpesh_9876543

It looks like you get the concept just fine. The only problems in your code are syntax related (and the poor practice of using conio.h). Fixing those errors produces working code: [code] #include<stdio.h> int main() { int counter,howmuch; printf("How many numbers do u want to print"); scanf("%d",&howmuch); counter=0; while (counter<=howmuch) …

Member Avatar for ilovec++
-2
158
Member Avatar for abdelhakeem

That's an interesting test, but somewhat unrealistic since the words are random. I found myself slowing down significantly (74 WPM) because I trip up when copying poorly constructed grammar.

Member Avatar for nick.crane
0
451
Member Avatar for Ali BAig
Member Avatar for Narue
-2
44
Member Avatar for winonus

You're redirecting stdin to the pipe, it won't read from the keyboard anymore. If you want to manage both piped data [i]and[/i] keyboard data, a better approach is opening the pipe within your program rather than redirecting input from the command line. For example: [code] #include <stdio.h> #include <string.h> #include …

Member Avatar for Narue
0
338
Member Avatar for menonnik

Most of the fast string searching algorithms can be applied to non-string arrays as well.

Member Avatar for menonnik
0
240
Member Avatar for Duki
Member Avatar for theCompiler

How are those words stored? Do you know about srand() and rand()? Are you just selecting a single word, or do they need to be randomly ordered? I'd start by storing the words in an array and then using rand() to get a random index into the array. This design …

Member Avatar for theCompiler
0
177
Member Avatar for apanimesh061

[QUOTE]No it is not a Class Assignment ![/QUOTE] That's irrelevant at this point. We're cracking down on "begging" questions, so in the future you may find similar threads to this one deleted. By "begging" we mean questions that fail to show proof of effort such as described [url=http://catb.org/~esr/faqs/smart-questions.html#before]here[/url].

Member Avatar for Narue
0
221
Member Avatar for bigdan182
Member Avatar for algotycoon

We're not a homework writing service. Please provide proof that you've made an honest attempt to solve the problem on your own.

Member Avatar for Muralidharan.E
-3
145
Member Avatar for missil9
Member Avatar for MooGeek

Why 50? Changing a user's name is quick and easy, provided the new name is available, so I don't see a problem with allowing it regardless of post count. Otherwise those with less than 50 posts would probably create a new account and take up both names, which just clutters …

Member Avatar for MooGeek
0
190
Member Avatar for Panathinaikos22

[QUOTE]That's like saying if you can nail two pieces of wood together and they don't fall apart then you are a carpenter.[/QUOTE] Your analogy neglects the "and are used" part. [QUOTE]I would have preferred to the the statement amended as[/QUOTE] I notice that you didn't change the offending statement that …

Member Avatar for Rashakil Fol
0
195
Member Avatar for Jason Giggs

[QUOTE]According to me,[/QUOTE] This is an odd phrase. Just saying. [QUOTE]this code should produce indefinite result because of no specified null character at the end of the string[/QUOTE] Correct. [QUOTE]Why is the null character present in the 13th memory location EACH TIME?[/QUOTE] In practice, it depends on how your compiler …

Member Avatar for mike_2000_17
0
96
Member Avatar for nishajain
Member Avatar for mrnutty

[QUOTE=mike_2000_17;1617747]Or maybe something along the lines of: [CODE] #include <iostream> #include <fstream> #include <string> using namespace std; int main() { ifstream infile("input.txt"); ofstream outfile("output.txt"); int value; while(infile >> value) { char mod_val = (--value) % 52; outfile << string(value / 52 + 1, (mod_val < 26 ? mod_val + 'a' …

Member Avatar for iamthwee
1
151
Member Avatar for techie929

Enumerations constants are symbolic constants representing integral values. If you want the string representation of the symbol, you must create it manually: [code] #include<stdio.h> int main(void) { enum days { one, two, three, four, five, six, seven, eight, nine, ten }; const char *days_str[] = { "one", "two", "three", "four", …

Member Avatar for Narue
0
119
Member Avatar for jimFan

>while (true) { You don't break from this loop anywhere. It's going to continue looping forever, after a short time getline will start to fail and you'll get the output you posted. Try this instead: [code] while ( getline ( cin, input ) ) cout << input << endl; [/code] …

Member Avatar for p9v9n261
0
461
Member Avatar for muktigeek

[QUOTE]what is output[/QUOTE] Unpredictable in all cases. [QUOTE]plz explain it..[/QUOTE] The expression [ICODE]a + !a + ~a + ++a[/ICODE] invokes undefined behavior by using the value of [ICODE]a[/ICODE] in a way that doesn't assist in computing the new value. It falls under the sequence point rule of an object being …

Member Avatar for Narue
0
103
Member Avatar for aiwasen

Your question is confusing, but the "limit" is based on the value of y, not the count of fibonacci numbers you've printed. Perhaps you wanted the latter?

Member Avatar for HASHMI007
0
185
Member Avatar for Daita

What does your book say? Did you search google? Have you made [i]any[/i] attempt to answer this trivial question on your own?

Member Avatar for HASHMI007
0
101
Member Avatar for fashxfreak

You might be able to get Visual C++ 2005 Express somewhere, but I don't believe Microsoft directly offers it anymore (they're up to 2010), so there's some risk involved. If you're asking for one of the non-express versions of Visual Studio, that's illegal.

Member Avatar for Ancient Dragon
0
108
Member Avatar for VernonDozier

[QUOTE]Line 23 will short-circuit if ptr is NULL and hence the CantGetHere() function won't be called, right?[/QUOTE] Correct. [QUOTE]Just want to confirm that ||, like &&, always works from left to right.[/QUOTE] Yes. Both are short circuited and have left to right associativity.

Member Avatar for VernonDozier
0
182
Member Avatar for jingda

It could be your IRC client. I've been logged in all morning with no issues.

Member Avatar for Dani
0
167
Member Avatar for Peter4n31

[QUOTE]Nathan memory is contious and it will always be for vectors, deques.[/QUOTE] For vectors, yes. For deques, there's no requirement that memory be contiguous.

Member Avatar for Narue
1
158
Member Avatar for deliezer

Are you setting an environment variable, or creating a symbol definition? Those are two completely separate things. Can you show an example of the make file?

Member Avatar for deliezer
0
2K
Member Avatar for tubby123

[QUOTE]How does this give 3, shouldnt it give 3*sizeof(int) cuz its an integer array.[/QUOTE] But it's not an int array, it's a char array.

Member Avatar for Adak
0
84
Member Avatar for s.w.a

The size of a character depends on the encoding for your character set. Do some research on ASCII and Unicode for details.

Member Avatar for JeffGrigg
0
104
Member Avatar for sadsdw

If you have a matrix in row major order, you can simply swap the indices to use column major order: [code] #include <iomanip> #include <iostream> using namespace std; int main() { const int n = 4; int mat[4][4] = { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, …

Member Avatar for sadsdw
0
223
Member Avatar for josh327

[URL="http://cboard.cprogramming.com/c-programming/88495-development-process.html"]Clicky[/URL].

Member Avatar for Narue
0
92
Member Avatar for Na'Vi

[QUOTE]I thought it was just getting the address of the first element of the array.[/QUOTE] That's exactly what it's doing. However, that address is being interpreted by scanf() as the starting address of a string. To print the address itself, use [ICODE]%p[/ICODE] and cast to [ICODE]void*[/ICODE]: [code] printf("%c %p %s\n", …

Member Avatar for Narue
0
80
Member Avatar for mrprassad

[QUOTE]and so, entry[i].interface = strtok (NULL, "\t"); returns 4th (i.e., last) token of (i+1)th line.[/QUOTE] All of the [ICODE]entry[i].interface[/ICODE] pointers point to [ICODE]buffer[/ICODE]. On each iteration of the loop, you change the contents of [ICODE]buffer[/ICODE]. Do you see the problem now?

Member Avatar for Narue
0
156
Member Avatar for turista

[QUOTE]codes always have to be OOP[/QUOTE] OOP for the sake of OOP, eh? Your teacher sounds like an idiot. [QUOTE]i have 3 but cant seem to find away to take one out.[/QUOTE] The easiest way would be combining the two from your inner loop with the conditional operator: [code] #include …

Member Avatar for turista
0
270
Member Avatar for ari$av3s

[QUOTE]argc is the counter of how many arguments that are passed in to the program (it is 1 with no additional arguments passed because it passes it's own path by default)[/QUOTE] argc is allowed to be zero. Further, even if argc is greater than zero, [ICODE]argv[0][/ICODE] is not required to …

Member Avatar for Narue
0
150
Member Avatar for ari$av3s

Here's an idea: write your own code from scratch instead of being a helpless baby. You'll learn a lot more than you would by cheating your way to a solution. Besides, those instructions are just a few steps shy of being a line for line description of the program. Do …

Member Avatar for Narue
0
115
Member Avatar for Serunson

[url]http://www.yui-net.com/[/url] My favorite is definitely "Good-Bye Days" from that album.

Member Avatar for blackcathacker
0
1K
Member Avatar for MooGeek
Member Avatar for jobs

[QUOTE=erigib89;1614435]What happens if this was a muti-threaded program?[/QUOTE] The same thing that happens when you have a single resource (the file in this case) and multiple threads trying to access it simultaneously. Concurrency safeguards would need to be added to the code.

Member Avatar for Narue
0
1K
Member Avatar for ohhmygod

[QUOTE]1. How do you guys pass char and string to a function (the correct way)?[/QUOTE] There's not really anything wrong with how you did it. [QUOTE]2. Is my code for counting a letter in a string the best way?[/QUOTE] I would only have minor nitpicks. The algorithm is sound.

Member Avatar for WaltP
0
3K
Member Avatar for agogte20

C and C++ are different languages. You don't need to learn any part of C before starting with C++. /thread

Member Avatar for mike_2000_17
0
131
Member Avatar for theguitarist

You want a compiler/IDE something that doesn't need to be installed on the host machine. Obviously that excludes Visual Studio. ;) IIRC, [URL="http://www.digitalmars.com/"]Digital Mars[/URL] is like that. If it's already built, MinGW can be "installed" simply by copying the files (I'd recommend the [URL="http://nuwen.net/mingw.html"]nuwen build[/URL]), and for an IDE Code::Blocks …

Member Avatar for Narue
0
169
Member Avatar for james6754

[QUOTE]I am studying C# at University but feel I may be rather restricted as to what I can do later on.[/QUOTE] Interesting. I haven't felt restricted with C#, and that's coming [i]from[/i] a C and C++ background. Though a lot of people associate C# with .NET rather than the internationally …

Member Avatar for Narue
0
172
Member Avatar for LevyDee

[QUOTE]This concept is fairly simple and I would assume that there is a good way to go about doing this.[/QUOTE] Assuming polymorphism doesn't work for some reason (usually due to violation of the substitution principle) then dynamic_cast can be used to discover the type. However, if you find yourself using …

Member Avatar for LevyDee
0
120
Member Avatar for jodzjcm

Your user array can only hold a single character. Since a string ends with '\0', that means it's always going to be empty. Further, using %s in scanf() without a field width means you're not respecting the lack of available space on the array. I'm totally unsurprised that the snippet …

Member Avatar for Narue
0
141
Member Avatar for priily

Your request lacks sufficient information, and it reeks of "please do it for me!". I suggest you read our rules, then how to ask a [URL="http://www.catb.org/~esr/faqs/smart-questions.html"]smart question[/URL].

Member Avatar for Narue
-1
61
Member Avatar for vincenzorm117

The problem is extraneous characters in the stream, but you might consider using scanf() to do the heavy lifting of reading only digits: [code] #include <stdio.h> int main(void) { char year[5]; int n; fputs("Enter year introduced: ", stdout); fflush(stdout); while (scanf("%4[0123456789]%n", year, &n) != 1 || n != 4) { …

Member Avatar for Narue
0
203
Member Avatar for Salem

[QUOTE]On the one hand, happygeek seems to think it's all about the quality.[/QUOTE] That's the ideal, yes. I'm open to ideas for [I]making[/I] people post quality content. [QUOTE]But when it comes to doing something about it, the enthusiasm seems to be more muted[/QUOTE] The problem is maintaining quality without being …

Member Avatar for Dani
0
235
Member Avatar for alwaysLearning0

I have no problem writing some examples for the wiki. As for the tutorial(s), if we're targeting beginners then a holistic approach might be better. Instead of just focusing on new features in isolation, it would be a complete beginner's tutorial on C++, but from the perspective of the new …

Member Avatar for mike_2000_17
1
161
Member Avatar for pseudorandom21

[QUOTE=pseudorandom21;1607660]I need to know a bit about this "default int" thing in C. What I mean is, is this actually ok and with what version of C is it ok? [code] main() { return 0; } [/code] As far as I knew this was standard modern C (i.e., no retarded …

Member Avatar for Narue
0
148

The End.