I like your version of code as it seems the most readable to me... However, there are a few parts of one line of code that I don't quite understand. Could you or someone explain this to me?
I'm...
Type: Posts; User: lucidrave
I like your version of code as it seems the most readable to me... However, there are a few parts of one line of code that I don't quite understand. Could you or someone explain this to me?
I'm...
Thanks.
Yeah, I guess I was just overthinking it a bit with that for-loop for x. I'll modify the code
I wrote some code today to accept user input for first and last names and then make sure it's formated as such: Randy Collins
So if the user types RaNDy or rANdY or randy it will format it and...
Ok I understand.
Thanks for the help on that everyone!
Ahh yes! That makes total since... It should have been obvious i is not the same as firstname[i]
Although another odd thing... If I put in the name "STEV0000EN"
at some point firstname will !=...
I changed NULL to simply 0 and I didn't get a warning. That makes sense...
Though I'm surprised my for loop worked because the condition is keep looping while firstname[i] is not zero, yet i...
My program compiles without any errors and runs perfectly, but I am getting a warning that I'm not sure about if you guys can give me some advice it would be most appreciated...
It says "warning:...
i see that firstname is a string and tolower won't accept strings, but if i did tolower( firstname[1] ); i figure tolower is only looking at the "R" in a name like "BRYAN"
if that doesn't work...
i figured since firstname is a string and that is just an array of characters than it would work. ok, i get that now
so do i need to do a loop until it reaches NULL /0 in the array and convert...
i'm not sure what the function prototype has to do with end of file. i think i'm probably using something i'm not advanced enough to be dealing with yet.
to me it looks like they are declaring c...
int tolower(int c);
ok... now i see it's a function prototype because of the ; at the end. however, the (int c) part throws me off a little... if (c) is supposed to be a character why don't they...
I posted a bad example... I thought it was C but I guess it was C++
I am studying C for now at least until I have a firm grasp on how to do everything I want to do.
A better example is the...
I've been asking questions on the boards here and have gotten some great help, and I have been learning to program C through a book that is pretty good (so far)
Anyway, there is going to be a time...
I guess what's confusing me is I thought %[^\n] was to ignore the new line, but then %*c also ignores the new line. isn't that redundant?
if %[^\n] doesn't work by itself should I not use it?
...
ohh ok... so it means ignore any characters after it sees the new line?
(in this code anyway)
I figured using a fflush(stdin); would clear the buffer but it doesn't seem to make a difference... I'm clueless how to get this working as expected
#include <stdio.h>
#include <string.h>
...
First off how does scanf know that this: %[^\n] is supposed to be formatted for a String? Shouldn't %s need to be in there? According to the syntax it's not supposed to be.
Anyway, my real...
thanks everyone! i understand the return statement pretty well now. i even corrected my code so it compiles and runs perfectly fine.
#include <stdio.h>
int AddNumbers( void );
int...
Before I continue on with my lessons in C, I want to make sure I understand the use of the Return statement within my own functions. From what I understand, when the program encounters the Return...
I'm reading through a great book on C but it hasn't done a great job making pointers easy to understand. What I'm having trouble with is not the concept of pointers (although I'm still not sure yet...
yeah, the next chapter in the book i'm reading talks about pointers and parameters... i haven't quite got there yet. i'm trying to master the different types of loops and understand when it is best...
Yeah! It works now! Thanks for the info guys, bithub's your tip got it working. But tabstop reminded me that for only works when a statement is true.
There are currently 5 marbles in the cup!...
I even simplified the code as much as I could (no function calls) and it only works if the value is 10... anything lower or higher doesn't work. Is my logic flawed here? Please help
#include...
there is no value in there because i'm just calling a function... if its under 10 then i call the function UnderTen();
Basically I'm trying to make this program so if you change the value of cupOfMarbles it will count up and print 5...6...7...8...9...10 and then stop (in this example) or if it is over 10 it will...