Thanks! There is still another problem with using fgets. If I want to enter and store a password using fgets, it will add a 0 at the end of my password? How do I make it not count the 0 at the end?
Type: Posts; User: mangekyou
Thanks! There is still another problem with using fgets. If I want to enter and store a password using fgets, it will add a 0 at the end of my password? How do I make it not count the 0 at the end?
Yeah I do, I get it, should i write
printf("%d\n", strlen(s1)-1);
gets(); gives a warning and scanf wont register spaces.
If I type "abc" using
scanf("%s" , s1);
printf("%d\n" , strlen(s1));
I get "3" which is correct. But when using
fgets(s1,10,stdin) I always get the number of characters I type in +1. Why?
How can I generate a random number between two numbers using stdlib?
printf("%d\n", rand() % 50); generates a number between 0 and 49, but how can I generate numbers between 10 and 20 or -10 and...
If I write 123456 or 1 2 3 4 5 6 or 1,2,3,4,5,6 and press enter. Or
1 (I press enter)
2 (enter)
....
Is there a way I can catch every single digit and store them as an int? If so, what is...
its supposed to be 1-6. I fixed that line by changinge to %6 +1.
Hi. I wrote a code that rolls a dice 3000 times and counts number of sixes rolled then prints the amount. I noticed that no matter how many times I ran the code, I didn't get 500+ sixes. I thought it...
Can you please tell me what I did wrong with this code?
#include <stdio.h>
int min(int x, int y);
int main(){
Thanks. I need to look more into it, functions are difficult :frown:
Good to hear! Is this the standard way of doing it even when writing bigger code that has many functions?
#include <stdio.h>
float eur2nok(float euro);
int main(){
On the cover of a modern approach, it says it only cover c89 and 99, is that a problem?
My teacher recommends this book:
P. J. Deitel H. M. Deitel,
C: How to program
Do you have any...
Does anyone have a book, video tutorial etc that they recommend for learning basic functions? My teacher uploads video lectures of all the basics of c programming but some of them, including the...
Got it, thanks. I thought there was a more efficient way than typing case after case .
for instance
instead of
case 'a':
case 'b':
case 'b':
I know how to write a switch case, type in a char "a" and run case "a"
But is it possible to somehow attach more than one value for what triggers the case?
for instance, instead of case 'a': case...
I understand now, thanks for clearing it up. I just started studying C and Im definitely not done studying for loops. Thank you for your help
When i goes from 0 to 1, the condition for i<n is no longer met, when jumping out of the loop and changing n from 1 to 2 and then going into the inner loop, I was expecting i to still be 1 and not go...
#include <stdio.h>
int main()
{
int n;
int i;
for (n=1; n<=5; n++)
{