|
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 January 29 2012 17:02 Crazyeyes wrote: Alright, I've got a little question for you guys. I'm currently in third year university, major in computer science. Before University, I honestly didn't even know what programming was.
So anyways. As I've mentioned, I'm third year. All of my knowledge in computer programming comes from my classes. I'll admit I'm not the best student, but I do pay attention when I can and I'm not exactly failing my way through this. I don't ever program on my free time or read programming-related things that aren't school related.
So far, we've pretty much only learned Java when it comes to useful programmming languages. I did a bit in Scheme, a very small amount in Assembly (I forgot most of it, honestly. It was horrible), some HTML... and I'm currently learning C. Much harder than I expected. Pointers sorta confuse me sometimes.
The thing is, I feel like I don't know anything. I feel like pepole who have way less education than me are more capable than I am. I've never said "I've made a script to do...." I dont even know what that is.
What I hope is going on is that I'm being given the basic (and hopefully more advanced, too) programming skills and knowledge that can be applied to all computer science, and then the more specific things I'll be able to pick up without too much effort. I'm hoping that when I sit down and am told to do X at some random job, I'll be able to do it and be surprised with how much I know. I'm just not very sure.
So, to any of you who come from a similar background (learned everything at school), can you shed some light on your situation? Is this normal?
I can say that this is a direct result of learning java first. I know lots of students who come from java without any prior programming experience and C/Assembly is horrible to them and they don't feel like know "anything."
Here's the basic truth.... Computer Science isn't all programming. Programming is how you APPLY the concepts you learn in computer science. To use an analogy, you're learning how to build a car from inside before actually building it ( programming ). Algorithms and data structures and classes like that teach you when to use a V8 engine rather than a V12 engine... etc etc.
So if I were to basically list out languages from lowest level to highest, it would sorta go like this: - Machine Language - Assembly - C - C++/Java/C#...
Machine Language is pretty useless to learn from what I've seen. Assembly is SUPER important because C/C++ code eventually gets translated to assembly. It's important to learn what happens on the lower levels when you create a function in C. You want to know how C sets up the stack and all that, and that's how knowing Assembly Language helps.
Anyway, I digress. As you learn C, you will realize that you'll slowly become "pro" at programming. No bullshit things like objects and code written for you in C. C really is a no-bullshit language, and you have to know exactly what you're doing or else you'll spend majority of your time fighting the code.
C will introduce you to wildly advanced topics like returning ANY type of data from a function (void pointers), passing entire functions as arguments, or returning entire functions ( function pointers )... hell you'll even learn neat tricks like optimizing switch statements by using function pointers. You'll learn EXACTLY when to pass things by reference and EXACTLY what happens inside your code. No more "let's change this and hope it works!" C is THE nerd's computer language. Most people in this thread will come in here and argue that java, python, whatever language they use is better and it might be true, but you don't "truly" learn to program unless you do so in C.
Once you're completely comfortable with the basics on C, I suggest you work on mastering these topics:
- OS APIs... ( WIN32 API, int 0x80 system calls.. ( basically linux system calls )... dunno what trashSX uses... ) - Network Programming ( Sockets, TCP/UDP ports, sending GET/POST through C for port 80 ) - Multi-threaded Programming - GUI Programming using OS APIs... Avoid using things like QT's drag and drop GUI builder because you won't learn anything - * This list in incomplete, but that's all that comes to my mind atm. I could mention things like global keyboard hooks, directX hooks, etc, but you'll discover those as you want to do certain projects. Will add stuff if I can remember it for the future! *
Once you've got all that down, you'll pretty much be able to program "anything." Your CS classes will come back remind you what search algorithms, data structures, and boolean logic to use to make your programs better.
At this point, when you move onto other languages it will be more about syntax. Your questions will shift from "Well how do I connect to a server?" to "Where can i find the socket API to this language?" You'll know what you need, and it will just be a matter of how to find it. I've gotten to a point where I can learn languages in about 2 hours. I learned how to program in matlab to help my friend out in under 20 minutes. I learned javascript programming for Adobe After Effects in about an hour and I was able to help visual effects artists modify various features of their shots by writing scripts for them.
That's my suggestion to you. Learn C, then go back and touch over assembly and you'll be able to program in anything.
Now... if you want to be a TRUE nerd and pwn EVERYONE at programming... start learning how to hack/crack/reverse engineer software. Hacking requires you know everything about everything, and it will open up your eyes to programming like you've never seen before. You'll learn how accidentally using a pointer after freeing it can cause a skilled programmer/hacker to compromise the entire system. Hacking is the CRUX of computers, and the most skilled programmers and computer scientists result from hacking. You can start off with a book called "The Shellcoder's Handbook" if you're interested in touching on the topic. That book is very technical and will really get you thinking about how things inside the computer work...
Ah, and just for some light reading... Here's a post by Linus Torvalds... the creator of the Linux operating system. I think this is hilariously interesting! + Show Spoiler +http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918
|
That's extremely helpful, actually, thanks!
Currently I'm taking a Parallel Programming and an Operating Systems class (both of which require me to use C), so I'm already starting on your list. I had a machine architecture class, but even though that was last year I've pretty much forgot everything. I hope the important things will come back when I need them.
I'm a lot more excited to learn C due to your post. :D
So another question: the hardest class I've taken so far was called "Introduction to Discrete Structures." It was just a math class. Half or more of the students were math majors. It was terrible, and we just learned about data sets and we did a lot of mathematical proofs (which was hard as fuck considering I didn't take a math proofs class until the semester afterwards). Do math-heavy things come in to play a lot?
I'll also stop hijacking the thread after this. :D
|
|
On January 29 2012 17:54 Abductedonut wrote:Show nested quote +On January 29 2012 17:02 Crazyeyes wrote: Alright, I've got a little question for you guys. I'm currently in third year university, major in computer science. Before University, I honestly didn't even know what programming was.
So anyways. As I've mentioned, I'm third year. All of my knowledge in computer programming comes from my classes. I'll admit I'm not the best student, but I do pay attention when I can and I'm not exactly failing my way through this. I don't ever program on my free time or read programming-related things that aren't school related.
So far, we've pretty much only learned Java when it comes to useful programmming languages. I did a bit in Scheme, a very small amount in Assembly (I forgot most of it, honestly. It was horrible), some HTML... and I'm currently learning C. Much harder than I expected. Pointers sorta confuse me sometimes.
The thing is, I feel like I don't know anything. I feel like pepole who have way less education than me are more capable than I am. I've never said "I've made a script to do...." I dont even know what that is.
What I hope is going on is that I'm being given the basic (and hopefully more advanced, too) programming skills and knowledge that can be applied to all computer science, and then the more specific things I'll be able to pick up without too much effort. I'm hoping that when I sit down and am told to do X at some random job, I'll be able to do it and be surprised with how much I know. I'm just not very sure.
So, to any of you who come from a similar background (learned everything at school), can you shed some light on your situation? Is this normal? I can say that this is a direct result of learning java first. I know lots of students who come from java without any prior programming experience and C/Assembly is horrible to them and they don't feel like know "anything." Here's the basic truth.... Computer Science isn't all programming. Programming is how you APPLY the concepts you learn in computer science. To use an analogy, you're learning how to build a car from inside before actually building it ( programming ). Algorithms and data structures and classes like that teach you when to use a V8 engine rather than a V12 engine... etc etc. So if I were to basically list out languages from lowest level to highest, it would sorta go like this: - Machine Language - Assembly - C - C++/Java/C#... Machine Language is pretty useless to learn from what I've seen. Assembly is SUPER important because C/C++ code eventually gets translated to assembly. It's important to learn what happens on the lower levels when you create a function in C. You want to know how C sets up the stack and all that, and that's how knowing Assembly Language helps. Anyway, I digress. As you learn C, you will realize that you'll slowly become "pro" at programming. No bullshit things like objects and code written for you in C. C really is a no-bullshit language, and you have to know exactly what you're doing or else you'll spend majority of your time fighting the code. C will introduce you to wildly advanced topics like returning ANY type of data from a function (void pointers), passing entire functions as arguments, or returning entire functions ( function pointers )... hell you'll even learn neat tricks like optimizing switch statements by using function pointers. You'll learn EXACTLY when to pass things by reference and EXACTLY what happens inside your code. No more "let's change this and hope it works!" C is THE nerd's computer language. Most people in this thread will come in here and argue that java, python, whatever language they use is better and it might be true, but you don't "truly" learn to program unless you do so in C. Once you're completely comfortable with the basics on C, I suggest you work on mastering these topics: - OS APIs... ( WIN32 API, int 0x80 system calls.. ( basically linux system calls )... dunno what trashSX uses... ) - Network Programming ( Sockets, TCP/UDP ports, sending GET/POST through C for port 80 ) - Multi-threaded Programming - GUI Programming using OS APIs... Avoid using things like QT's drag and drop GUI builder because you won't learn anything - * This list in incomplete, but that's all that comes to my mind atm. I could mention things like global keyboard hooks, directX hooks, etc, but you'll discover those as you want to do certain projects. Will add stuff if I can remember it for the future! * Once you've got all that down, you'll pretty much be able to program "anything." Your CS classes will come back remind you what search algorithms, data structures, and boolean logic to use to make your programs better. At this point, when you move onto other languages it will be more about syntax. Your questions will shift from "Well how do I connect to a server?" to "Where can i find the socket API to this language?" You'll know what you need, and it will just be a matter of how to find it. I've gotten to a point where I can learn languages in about 2 hours. I learned how to program in matlab to help my friend out in under 20 minutes. I learned javascript programming for Adobe After Effects in about an hour and I was able to help visual effects artists modify various features of their shots by writing scripts for them. That's my suggestion to you. Learn C, then go back and touch over assembly and you'll be able to program in anything. Now... if you want to be a TRUE nerd and pwn EVERYONE at programming... start learning how to hack/crack/reverse engineer software. Hacking requires you know everything about everything, and it will open up your eyes to programming like you've never seen before. You'll learn how accidentally using a pointer after freeing it can cause a skilled programmer/hacker to compromise the entire system. Hacking is the CRUX of computers, and the most skilled programmers and computer scientists result from hacking. You can start off with a book called "The Shellcoder's Handbook" if you're interested in touching on the topic. That book is very technical and will really get you thinking about how things inside the computer work... Ah, and just for some light reading... Here's a post by Linus Torvalds... the creator of the Linux operating system. I think this is hilariously interesting! + Show Spoiler +http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918
Damn, that linux link was interesting. Your response was articulated much better than I could have hoped to do, that was an excellent read.
@Crazyeyes, I was in the exact same boat last year. I was a third year who had only ever done TI-83+ programming, and sort of came to the major by accident. Then I got a job at a career fair, and my confidence soared. Frankly I didn't know jack**** about any of the languages I needed to, but what I did know was the concepts. Learning languages, APIs, etc is surprisingly easy once you've got a decent grasp on your first few.
I did have the advantage of learning C first though, which I didn't really appreciate at the time. (Looking back, I'm very glad I had the low-level overview because I would have been severely lost in several major projects since then if it weren't for the foundation in C).
Anyway, my advice is to get ANY kind of employment, paid, with the school, with a group of friends, or otherwise, and learn from there. I look back and find myself SHOCKED at how utterly unqualified I was for this position 6 months ago. You end up learning a ton through trial and error, but the concepts at college give you a really good foundation. You're learning how to learn, and after that it's up to you to apply it.
One more thing - I used to be intimidated by phrases like 'running scripts', etc. (Lot's of nerdy friends). It's not nearly as impressive as it sounds. Useful, but not difficult.
|
Hyrule18975 Posts
Scripts are amazing. Never understate their importance :O
also that's going in the OP. Very good info
|
On January 29 2012 17:54 Abductedonut wrote:Show nested quote +On January 29 2012 17:02 Crazyeyes wrote: Alright, I've got a little question for you guys. I'm currently in third year university, major in computer science. Before University, I honestly didn't even know what programming was.
So anyways. As I've mentioned, I'm third year. All of my knowledge in computer programming comes from my classes. I'll admit I'm not the best student, but I do pay attention when I can and I'm not exactly failing my way through this. I don't ever program on my free time or read programming-related things that aren't school related.
So far, we've pretty much only learned Java when it comes to useful programmming languages. I did a bit in Scheme, a very small amount in Assembly (I forgot most of it, honestly. It was horrible), some HTML... and I'm currently learning C. Much harder than I expected. Pointers sorta confuse me sometimes.
The thing is, I feel like I don't know anything. I feel like pepole who have way less education than me are more capable than I am. I've never said "I've made a script to do...." I dont even know what that is.
What I hope is going on is that I'm being given the basic (and hopefully more advanced, too) programming skills and knowledge that can be applied to all computer science, and then the more specific things I'll be able to pick up without too much effort. I'm hoping that when I sit down and am told to do X at some random job, I'll be able to do it and be surprised with how much I know. I'm just not very sure.
So, to any of you who come from a similar background (learned everything at school), can you shed some light on your situation? Is this normal? I can say that this is a direct result of learning java first. I know lots of students who come from java without any prior programming experience and C/Assembly is horrible to them and they don't feel like know "anything." Here's the basic truth.... Computer Science isn't all programming. Programming is how you APPLY the concepts you learn in computer science. To use an analogy, you're learning how to build a car from inside before actually building it ( programming ). Algorithms and data structures and classes like that teach you when to use a V8 engine rather than a V12 engine... etc etc. So if I were to basically list out languages from lowest level to highest, it would sorta go like this: - Machine Language - Assembly - C - C++/Java/C#... Machine Language is pretty useless to learn from what I've seen. Assembly is SUPER important because C/C++ code eventually gets translated to assembly. It's important to learn what happens on the lower levels when you create a function in C. You want to know how C sets up the stack and all that, and that's how knowing Assembly Language helps. Anyway, I digress. As you learn C, you will realize that you'll slowly become "pro" at programming. No bullshit things like objects and code written for you in C. C really is a no-bullshit language, and you have to know exactly what you're doing or else you'll spend majority of your time fighting the code. C will introduce you to wildly advanced topics like returning ANY type of data from a function (void pointers), passing entire functions as arguments, or returning entire functions ( function pointers )... hell you'll even learn neat tricks like optimizing switch statements by using function pointers. You'll learn EXACTLY when to pass things by reference and EXACTLY what happens inside your code. No more "let's change this and hope it works!" C is THE nerd's computer language. Most people in this thread will come in here and argue that java, python, whatever language they use is better and it might be true, but you don't "truly" learn to program unless you do so in C. Once you're completely comfortable with the basics on C, I suggest you work on mastering these topics: - OS APIs... ( WIN32 API, int 0x80 system calls.. ( basically linux system calls )... dunno what trashSX uses... ) - Network Programming ( Sockets, TCP/UDP ports, sending GET/POST through C for port 80 ) - Multi-threaded Programming - GUI Programming using OS APIs... Avoid using things like QT's drag and drop GUI builder because you won't learn anything - * This list in incomplete, but that's all that comes to my mind atm. I could mention things like global keyboard hooks, directX hooks, etc, but you'll discover those as you want to do certain projects. Will add stuff if I can remember it for the future! * Once you've got all that down, you'll pretty much be able to program "anything." Your CS classes will come back remind you what search algorithms, data structures, and boolean logic to use to make your programs better. At this point, when you move onto other languages it will be more about syntax. Your questions will shift from "Well how do I connect to a server?" to "Where can i find the socket API to this language?" You'll know what you need, and it will just be a matter of how to find it. I've gotten to a point where I can learn languages in about 2 hours. I learned how to program in matlab to help my friend out in under 20 minutes. I learned javascript programming for Adobe After Effects in about an hour and I was able to help visual effects artists modify various features of their shots by writing scripts for them. That's my suggestion to you. Learn C, then go back and touch over assembly and you'll be able to program in anything. Now... if you want to be a TRUE nerd and pwn EVERYONE at programming... start learning how to hack/crack/reverse engineer software. Hacking requires you know everything about everything, and it will open up your eyes to programming like you've never seen before. You'll learn how accidentally using a pointer after freeing it can cause a skilled programmer/hacker to compromise the entire system. Hacking is the CRUX of computers, and the most skilled programmers and computer scientists result from hacking. You can start off with a book called "The Shellcoder's Handbook" if you're interested in touching on the topic. That book is very technical and will really get you thinking about how things inside the computer work... Ah, and just for some light reading... Here's a post by Linus Torvalds... the creator of the Linux operating system. I think this is hilariously interesting! + Show Spoiler +http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918
This post is 100% spot on, GOLDEN! The list pretty much sums up everything nicely.
I would like to add opengl/directx programming, but then again its prolly too much math to be useful in other fields, although personally I think graphic programming is amongst the hardest tasks in programming.
If you have no hobby project, you can always try write a basic game engine. Start with stuff like memory, input, audio, etc.. but if you don't have alot of experience (as is sounds like) its prolly to big task
|
Hello programming thread,
Allright my current situation is that I have 6 months, which means I have some time to spare. I basically want to be proficient in C before I start.
My question to you is what are good tools for learning C? I've checked out some youtube tutorials, but most of them don't go too much in depth. If you have any books, videos, or websites to recommend, that would be great. I checked out cprogramming.com, but it doesn't really help me much, since it provides rather general and useless examples.
My main topic of confusion is pointers, don't know if that helps.
I already have some prior experience (although quite basic) in mainly Scheme and Actionscript(experimented some with flash).
|
On February 02 2012 16:09 Grndr101 wrote: Hello programming thread,
Allright my current situation is that I have 6 months, which means I have some time to spare. I basically want to be proficient in C before I start.
My question to you is what are good tools for learning C? I've checked out some youtube tutorials, but most of them don't go too much in depth. If you have any books, videos, or websites to recommend, that would be great. I checked out cprogramming.com, but it doesn't really help me much, since it provides rather general and useless examples.
My main topic of confusion is pointers, don't know if that helps.
I already have some prior experience (although quite basic) in mainly Scheme and Actionscript(experimented some with flash).
Hey dude, the way I taught myself what I know about C is basically by just going through tutorials and videos (which is sounds like you're doing already) and trying out some simple applications. Also learning out to make "Makefiles" is really important. Really, it's just time and persistence and going from one level of difficulty to another.
Most tutorials online are very "step by step" and in order of difficulty. If you really want to make the best of your 6 months and have some spare money, I suggest going for an online course. HEAPS of online Universities / Colleges run C courses and you will have tons of podcast lectures / tutorials / interaction with other students to get you proficient faster.
|
Hi Programming thread,
I am an iOS developer (cocos2d mainly).
For those with iPhones, I highly recommend learning objective-C. Its not as hard as say C++ and nothing beats showing off software you develop to your friends on your mobile phone.
|
On February 02 2012 16:09 Grndr101 wrote: Hello programming thread,
Allright my current situation is that I have 6 months, which means I have some time to spare. I basically want to be proficient in C before I start.
My question to you is what are good tools for learning C? I've checked out some youtube tutorials, but most of them don't go too much in depth. If you have any books, videos, or websites to recommend, that would be great. I checked out cprogramming.com, but it doesn't really help me much, since it provides rather general and useless examples.
My main topic of confusion is pointers, don't know if that helps.
I already have some prior experience (although quite basic) in mainly Scheme and Actionscript(experimented some with flash).
I think you can't go wrong with C Programming Language (2nd Edition) by Brian W. Kernighan and Dennis M. Ritchie.
As far as I remember (where the hell is my copy :D) it includes lots of exercises and stuff too. If you work through the exercises you should be good to go 
|
jca2
France52 Posts
My two cents about programming: if you intend to become a professional software developer, programming is only a mean to achieve a higher goal: produce quality software applications. So all that was said about learning C, C++, Win32, .NET, etc is valid, but it's only step 1 (By the way, you don't need to learn all the programming technologies around. It's better to know a few of them really really well than to be mediocre everywhere).
Step 2 is everything that will help you write good code, solid code, clean code, efficient code, with good architecture, good workflow, good user interface, proper documentation, good planning, etc, because that will lead to good applications and software projects delivered on time. When you design and write code for commercial products, in most cases, all of that matters more than being a wiz at any given technology.
Therefore, I would recommend reading not only programming books but also books about software development. There are many out there. A few immediately come to mind:
Writing Solid Code by Steve Maguire Code Complete by Steve McConnell
Other authors to look for:
Jim McCarthy Andrew Hunt Scott Meyers Edward yourdon Edsger Dijkstra
And of course, if you are into C and C++:
Brian Kernighan Bjarne Stroustrup
Finally, read books, write code, plenty of code, then read more books and write more code. Then get to work on a commercial product, within a decent software team, for a few decades. That's how you get good.
"The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague. " Edsger W. Dijkstra
|
Ok, first I want to say thank you to all of you for your answers. Very helpful to not only get information, but your oppinions on learning to program.
Secondly, I stumbled on THIS blog. Which explains a lot about C functions I didn't know.
However there is a bit of code that leaves me confused.
+ Show Spoiler +#include <stdio.h> int main() { int v; // value read from scanf int r; // return value from scanf int e; // error count e = 0; // initialize to no errors do { r = scanf("%d", &v); if (!r) e++; // if error, count it printf(" %3d Read, return %d \n", v, r); } while ((v != 0) && (e < 4)); return 0; }
If you want it's also available in the blog entry in more pleasing format.
Thus my question is: -how come if my input is '55 66 77', does it print out all 3 integer values?
If I try to read in 3 integers separated by spaces in a scanf() function(without the while loop), it only stores the first one in the variable. Then if I print it out it prints out one.
If I'm being imprecise please say so. And thanks again.
|
The %d in the function scanf is saying "I expect to be given an integer". It parses the user input until it receives a non-integer character (like a space), then stores the number that it just scanned into the variable v. If i'm understanding you correctly, you have a single scanf() function, and it's storing 55 into the variable v when given the input '55 66 77'. This behavior is correct, because it read your input until the first non integer character (space). Without the while loop, it doesn't even read the 66 and 77 characters.
Perhaps if you gave a second code sample we could tell you why it's behaving that way.
|
Hm I'll try to explain more clearly
The input is '55 66 77'
Meaning you type 55, space, 66, space and 77 and hit enter.
Code 1 + Show Spoiler + #include <stdio.h> int main() { int v; // value read from scanf int r; // return value from scanf int e; // error count e = 0; // initialize to no errors do { r = scanf("%d", &v); if (!r) e++; // if error, count it printf(" %3d Read, return %d \n", v, r); } while ((v != 0) && (e < 4)); return 0; }
output : 55 Read, return 1 66 Read, return 1 77 Read, return 1
Code 2:
+ Show Spoiler +
#include <stdio.h> int main() {
int v; // value read from scanf int r; // return value from scanf
r = scanf("%d", &v); printf(" %3d Read, return %d \n", v, r); return 0; }
Output: 55 Read, return 1
Hence my question why both behave differently. The first one outputs the 3 ints while the second one outputs 1 int. Maybe I'm reading the loop wrong, but in my eyes it should store the value in v, print read 55, return 1 and then overwrite that value with the r= scanf("%d", &v); statement.
Thanks for your patience, lol.
|
No problem, the reason the behavior is different is because of the 'while' loop. In code 1, you'll notice do{ ... }while((v!=0)&&(e<4))
This statement will continue to execute whatever is in the do-while loop (in your case, scanf and printf) AS LONG AS the conditions within while() are met.
When v is zero (i.e. you enter 0 as an input integer) OR you make 4 errors, it breaks out of the loop. The reason 55 66 77 scans and prints 3 integers is that it goes through 3 iterations of the while loop. It never detects the 'exit condition', so it loops through that bit of code.
simple example:
int count = 0; count += 1; printf("%d",count); //prints 1
int count = 0; do{ count += 1 }while(count < 5); printf("%d",count); //prints 5
Essentially, his code is calling scanf three separate times because it loops through the while-loop without reaching an exit condition. Your code has no loop, so scanf is called a single time.
Makes sense?
|
I'm confused.
Let me explain what I have in my head.
In the do.. while loop the loop will execute the statements one time(to at least get input once). Then it will check the condition and run trough the loop again if it is true.
So let me explain what I think should happen each iteration.
1.r = scanf("%d", &v); the loop runs the scanf function, assigning the value of the input to v, then stores the returned value in variable r. In the case of the input I mentioned this should be 55.
2. if (!r) e++; if error, count it
3. printf(" %3d Read, return %d \n", v, r); return the formatted value of v and r.
So I don't get why with the input I gave it it could print the 3 values of 55, 66 and 77 In my mind it should print the value 55, then overwrite this value in the next loop with a user input (ie: you enter 93). At work not much time.
|
Ok I think I get it. http://en.wikipedia.org/wiki/Scanf_format_string
check out the first code example here. Essentially, scanf treats whitespace of ANY kind as a delimiter - so when you press enter and your input is '55 66 77', it consumes input until it reaches, whitespace, but it DOESN'T throw away the rest of the input - that's still waiting in the stdin buffer. When you go through the next loop iteration, it consumes the 66 that is waiting.
Essentially, pressing enter sends whatever text is on the commandline into the stdin buffer. Scanf parses the first int, then the loop calls scanf again until the input buffer is empty.
|
On February 02 2012 17:00 Neelia wrote:Show nested quote +On February 02 2012 16:09 Grndr101 wrote: Hello programming thread,
Allright my current situation is that I have 6 months, which means I have some time to spare. I basically want to be proficient in C before I start.
My question to you is what are good tools for learning C? I've checked out some youtube tutorials, but most of them don't go too much in depth. If you have any books, videos, or websites to recommend, that would be great. I checked out cprogramming.com, but it doesn't really help me much, since it provides rather general and useless examples.
My main topic of confusion is pointers, don't know if that helps.
I already have some prior experience (although quite basic) in mainly Scheme and Actionscript(experimented some with flash). I think you can't go wrong with C Programming Language (2nd Edition) by Brian W. Kernighan and Dennis M. Ritchie. As far as I remember (where the hell is my copy :D) it includes lots of exercises and stuff too. If you work through the exercises you should be good to go  A practical online reference: http://www.acm.uiuc.edu/webmonkeys/book/c_guide/index.html
|
I'm looking for programmers interested in C, abstract algebra, cryptography, or distributed systems to help with a FOSS project. Great for math/CS undergrads or high-school students who want to pad their resume.
pm for details.
User was warned for this post
|
I'm looking for programmers interested in web design, graphics, animation, and free software to help design & develop a FOSS web toolkit.
pm for details.
User was warned for this post
|
|
|
|