Search:

Type: Posts; User: mangekyou

Search: Search took 0.00 seconds.

  1. Replies
    8
    Views
    8,153

    Thanks! There is still another problem with using...

    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?
  2. Replies
    8
    Views
    8,153

    Yeah I do, I get it, should i write ...

    Yeah I do, I get it, should i write
    printf("%d\n", strlen(s1)-1);
    gets(); gives a warning and scanf wont register spaces.
  3. Replies
    8
    Views
    8,153

    strlen adds +1 to length when using fgets

    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?
  4. how to generate random number between two numbers?

    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...
  5. Replies
    2
    Views
    2,335

    how to grab values from a line?

    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...
  6. Replies
    10
    Views
    5,173

    its supposed to be 1-6. I fixed that line by...

    its supposed to be 1-6. I fixed that line by changinge to %6 +1.
  7. Replies
    10
    Views
    5,173

    what went wrong with this code?

    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...
  8. Replies
    4
    Views
    2,202

    some problem with my code

    Can you please tell me what I did wrong with this code?


    #include <stdio.h>


    int min(int x, int y);


    int main(){
  9. Replies
    11
    Views
    2,715

    Thanks. I need to look more into it, functions...

    Thanks. I need to look more into it, functions are difficult :frown:
  10. Replies
    11
    Views
    2,715

    Good to hear! Is this the standard way of doing...

    Good to hear! Is this the standard way of doing it even when writing bigger code that has many functions?
  11. Replies
    11
    Views
    2,715

    is it ok to write code like this?

    #include <stdio.h>




    float eur2nok(float euro);


    int main(){
  12. Replies
    3
    Views
    4,590

    On the cover of a modern approach, it says it...

    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...
  13. Replies
    3
    Views
    4,590

    reccomandations for learning functions?

    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...
  14. Replies
    3
    Views
    2,371

    Got it, thanks. I thought there was a more...

    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':
  15. Replies
    3
    Views
    2,371

    attaching more values to a case

    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...
  16. Replies
    5
    Views
    9,309

    I understand now, thanks for clearing it up. I...

    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
  17. Replies
    5
    Views
    9,309

    When i goes from 0 to 1, the condition for i

    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...
  18. Replies
    5
    Views
    9,309

    why does the value in for loop reset?

    #include <stdio.h>


    int main()
    {
    int n;
    int i;

    for (n=1; n<=5; n++)
    {
Results 1 to 18 of 18