|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On October 02 2014 10:03 tofucake wrote:Show nested quote +On October 02 2014 08:46 YourGoodFriend wrote:On October 02 2014 07:38 tofucake wrote: we don't talk about w3schools around here Well for JavaScript Mozilla documentation is definitely better. But w3 isn't too bad http://www.w3fools.com/
I'm not really sure I understand your objective with these types of posts. The ultimate goal should be teaching or helping, not just holding a better than thou type attitude. The guy was at least trying to help, unlike your posts.
I don't use w3schools, nor am I claiming its the best resource ever, but its available and they are trying to provide information to help others. I think Paul Irish says it best on his own github acct.
I'd like to wind down the tone of the site and use it to share positivity. We can recommend evaluating your learning sources, prioritize testing over trusting, and point to how to better develop your knowledge and participation in the community.
I get that it was cool to bash w3schools, but, it just seems less than helpful.
|
Hyrule19173 Posts
W3schools is a bad resource. I don't bash it because it's "the cool thing to do".
|
|
|
Hello!
Code + Show Spoiler + #include <stdio.h> #include <time.h> #include <stdlib.h>
int main(void)
{ srand( time(NULL) ); int secretNumber = rand()%100 + 1; int guess = 0; int counter = 0; char input; printf("Number is %d\n", secretNumber); printf("I'm thinking of a number between 1 and 100\n"); printf("What is your guess?\n");
while(1) { counter++; scanf("%d", &guess); if (guess == secretNumber) { { printf("It took you %d tries\n", counter); printf("Play again? (y/n)?"); scanf("%c", &input); } { break; } } if (guess < secretNumber) { printf("Too low!\n"); } if (guess > secretNumber) { printf("Too high!\n"); } }
system("PAUSE"); return 0;
}
Problem:
I can't figure out how to get the program to start again if I press "y" when it asks "Play again (y/n)?". I've come to the conclusion that I should use some sort of
do { code here } while (input == 'y');
but I can't get it to work. :/
|
made acquaintance with as-needed in gcc today. gcc kept ripping all out the libraries i wanted to link, didn't notice it happening before i wrote the simplest of makefiles and ldd'd the binary. grrr...
|
On October 03 2014 00:08 _Grazze_ wrote: Hello!
do { code here } while (input == 'y');
but I can't get it to work. :/
You are ALMOST there. Won't give you the answer though but you are right on track in using a while loop 
|
|
|
|
|
On October 03 2014 00:42 icystorage wrote:Show nested quote +On October 03 2014 00:08 _Grazze_ wrote: Hello!
do { code here } while (input == 'y');
but I can't get it to work. :/ You are ALMOST there. Won't give you the answer though  but you are right on track in using a while loop 
I'm just skipping this one lol.
I got it to work if I changed my scanf(%c, &input) to scanf(%d, &input) and changed input to an integer = 1;
So when I pressed 1 when it asked me to play again it worked haha, but not with characters.
|
I'm learning C++ but my programming background is Java. I have to say though, Java's generics look like complete bullshit compared to C++ 'loose' templates. I like C++ so far even though it may not be as safe as Java.
|
On October 03 2014 04:15 darkness wrote:I'm learning C++ but my programming background is Java. I have to say though, Java's generics look like complete bullshit compared to C++ 'loose' templates. I like C++ so far even though it may not be as safe as Java.  While templates are much like more powerful generics, that'a just a glimpse of the power of templates. Templates are compile-time turing complete.
|
On October 03 2014 01:25 Nesserev wrote:![[image loading]](http://www.emacswiki.org/pics/static/TabsSpacesBoth.png) Definitely spaces... for some reason, tabs make me feel dirty.
Vimrc!
set autoindent set shiftwidth=4 " 1 tab = 4 spaces (autoindent) set softtabstop=4 " 1 tab = 4 spaces (tab key) set expandtab " never use hard tabs set shiftround " only indent to multiples of shiftwidth set smarttab
Definitely spaces, but the tab key is still handy.
|
Yay I figured out how to separately trim the numbers from the string e.g. "Page 56 of 95[EXTRACT]" (where the string can be smaller or larger than this in length e.g. "Page 2 of 95[EXTRACT]" is smaller in length and we need some way to detect this). YAY.
This is how I done it (vbs) + Show Spoiler +example string: "Page 55 of 85[EXTRACT]" pageNumberPage = Mid(pageNumberExtract, 5, (InStr(pageNumberExtract, "of")-6)) 'start at char 5 (constant) and give us X characters equal to position of "of" - 6 (due to starting +5) pageNumberOfPage = Mid(pageNumberExtract,(InStr(pageNumberExtract, "of")+2),((InStr(pageNumberExtract,"EX")-1)-(InStr(pageNumberExtract, "of")+2))) 'start at (position of "of"+2 and give us X characters equal to ( position of "EX" -1 (eg 14)) minus ( position of "of" +2 (eg 10)) msgbox("pageOf " + pageNumberPage + " ofPage " + pageNumberOfPage)
output: pageOf 77 ofPage 95
I set my checkPageNumbers function to 0 if pageOf = ofPage because it means we've run to the final page of the website and if the function is 0 then my "do this on every page" function exits its loop because we no longer need to "do this on every page".
I am smart.
Anyone want to comment on the way I trimmed the string? It looks retarded complicated and took me 1-2 hours.
Also anyone want to comment on how I named variables here? E.g. pageOf. I thought just calling it page was a bit too vague but pageOf looks weird too.
PS I probably should test this more before posting it LOL
|
On October 03 2014 00:53 Nesserev wrote:Show nested quote +On October 03 2014 00:14 nunez wrote: made acquaintance with as-needed in gcc today. gcc kept ripping all out the libraries i wanted to link, didn't notice it happening before i wrote the simplest of makefiles and ldd'd the binary. grrr... Wait, why was it 'ripping out' the libraries?? The as-needed flag should normally not cause any problems, right? i had never faced it before, so i was quite bemused when it did not find symbols that i knew were in the libraries i linked against, and after a cursory google it seemed like there were some caveats for us uninitiated, relating to ordering of stuff (possibly)... but i did not dwell on it, i just turned it off. it was just a minor assignement.
|
On October 03 2014 04:09 _Grazze_ wrote:Show nested quote +On October 03 2014 00:42 icystorage wrote:On October 03 2014 00:08 _Grazze_ wrote: Hello!
do { code here } while (input == 'y');
but I can't get it to work. :/ You are ALMOST there. Won't give you the answer though  but you are right on track in using a while loop  I'm just skipping this one lol. I got it to work if I changed my scanf(%c, &input) to scanf(%d, &input) and changed input to an integer = 1; So when I pressed 1 when it asked me to play again it worked haha, but not with characters.
Don't change your 'input' variable to int. char is fine. Just make sure that you read:
http://stackoverflow.com/a/14419972/1091781
Edit: Nevermind, you already propose a do-while loop to check user's choice.
You may also consider transferring your number guessing code into a function or more, so whenever the user types 'y', you just reuse that function to generate a new number to guess as well as to restart game.
|
|
|
On October 03 2014 04:23 FFGenerations wrote:Yay I figured out how to separately trim the numbers from the string e.g. " Page 56 of 95 [EXTRACT]" (where the string can be smaller or larger than this in length e.g. " Page 2 of 95 [EXTRACT]" is smaller in length and we need some way to detect this). YAY. This is how I done it (vbs) + Show Spoiler +example string: "Page 55 of 85[EXTRACT]" pageNumberPage = Mid(pageNumberExtract, 5, (InStr(pageNumberExtract, "of")-6)) 'start at char 5 (constant) and give us X characters equal to position of "of" - 6 (due to starting +5) pageNumberOfPage = Mid(pageNumberExtract,(InStr(pageNumberExtract, "of")+2),((InStr(pageNumberExtract,"EX")-1)-(InStr(pageNumberExtract, "of")+2))) 'start at (position of "of"+2 and give us X characters equal to ( position of "EX" -1 (eg 14)) minus ( position of "of" +2 (eg 10)) msgbox("pageOf " + pageNumberPage + " ofPage " + pageNumberOfPage)
output: pageOf 77 ofPage 95 I set my checkPageNumbers function to 0 if pageOf = ofPage because it means we've run to the final page of the website and if the function is 0 then my "do this on every page" function exits its loop because we no longer need to "do this on every page". I am smart. Anyone want to comment on the way I trimmed the string? It looks retarded complicated and took me 1-2 hours. Also anyone want to comment on how I named variables here? E.g. pageOf. I thought just calling it page was a bit too vague but pageOf looks weird too. PS I probably should test this more before posting it LOL
I've never written vbs before. But looks convoluted. Ever tried Split?
page_number_split = Split(page_number_extract) page_number = page_number_split(1) extract_idx = InStr(page_number_split(3), "[EXTRACT]") total_number_of_pages = Left(page_number_split(3), extract_idx)
For naming, I recommend the above. Admittedly does not look as nice in camelCase.
|
|
|
hi guys, can you please have a look at this and tell me why my Wscript.exe stays in task manager when i randomly close the application? I'm trying to figure out where to put this shit to catch whatever error it gets when you randomly close it..... it no longer shows an error message when you randomly close it, but wscript stays running in task manager
+ Show Spoiler + On Error Resume Next
Do
Do While checkSortBy() = 0
If horizontalNumber = -1 Then
iret = iim1.iimClose WScript.Quit(iret)
ElseIf checkNextLinkExists() Then
clickLink() modifyControlValues()
Else
clickPreviousLink()
End If
Loop
extract()
clickPreviousLink()
Loop
objFileSystem.Close strOutputFile.Close iret = iim1.iimClose WScript.Quit(iret)
|
Are you not just in a big Do Loop? Even if you close the program, you don't seem to have anything that will break the Do Loop. I don't know that language, but you may need an equivalent of ThreadAbortException, or something that actually exits the loop?
|
|
|
|
|
|