Search:

Type: Posts; User: alter.ego

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Great! Thank you very much. Got it.

    Great! Thank you very much. Got it.
  2. I agree I messed up with the braces and the...

    I agree I messed up with the braces and the title. This was under captioned chapter hence I posted it that way. Sorry.


    void squeeze(char s[], char c)
    {
    int i, j;
    for (i = j = 0; s[i] != '\0';...
  3. Trying to understand increment & decrement operators

    K&R trying to explain increment & decrement operator through this illustration:


    /* squeeze: delete all c from s */
    void squeeze(char s[], int c)
    {
    int i, j;
    for (i = j = 0; s[i] != '\0';...
  4. Replies
    5
    Views
    1,331

    @std10093 @Barney Now it does look quite obvious....

    @std10093 @Barney Now it does look quite obvious. Thanks for your help.
  5. Replies
    5
    Views
    1,331

    Thanks! So you saying (in other words) while that...

    Thanks! So you saying (in other words) while that concatenation is happening it's not getting printed because of '\0'?
  6. Replies
    5
    Views
    1,331

    Basic strcat query from k&r book

    I am trying to understand postfix & prefix increment and decrement operators from K&R book. They have given a string concatenation example:


    /* strcat: concatenate t to end of s; s must be big...
  7. Problem in solving a character array problem from K&R book

    Excercise:


    My solution has not taken the final shape. Right now I am stuck in the last else-if. Program is working fine if l < 4 but not when l>4. I've been trying to debug for a while before...
  8. ^^ Thanks! Haven't yet reached the chapter on...

    ^^ Thanks! Haven't yet reached the chapter on Pointers & will definitely refer it once I am there.
  9. Great! Much clearer now. Thanks!

    Great! Much clearer now. Thanks!
  10. Thanks guys, much appreciated. But what about,...

    Thanks guys, much appreciated. But what about, say there was another function say CountWord(...,...), taking input as another character array, how would have copy() responded then?
  11. A very silly question on character arrays but I will ask it.

    This code is a direct paste from K&R:


    #include <stdio.h>
    #define MAXLINE 1000 /* maximum input line length */
    int getline(char line[], int maxline);
    void copy(char to[], char from[]); /*...
  12. Replies
    5
    Views
    2,003

    Whoops! HOW DID I MISS IT!!!? Also I did an...

    Whoops! HOW DID I MISS IT!!!?

    Also I did an elementary mistake of keeping ++i outside the loop & it kept getting reseted to 0. Code works now!


    Thanks hk_mp5kpdw, itsme86 & AndiPersti for all...
  13. Replies
    5
    Views
    2,003

    How do I use macro in the function, I may get an...

    How do I use macro in the function, I may get an 'undefined variable error' (apologies if I am missing on something)?

    Thanks for pointing it out. My minor tweaked code is as under, pasting it...
  14. Replies
    5
    Views
    2,003

    Character array problem

    I am trying to solve this problem from K&R book.



    My solution

    #include <stdio.h>
    #include <stdlib.h>
    #define MAXLINE 10
  15. Thanks! That helped & thanks for giving reasons...

    Thanks! That helped & thanks for giving reasons behind it too.
  16. Cannot figure out this bug "error: conflicting types"

    Hi,

    I am trying to work on a "simple" problem from K&R book. The excercise is as under:



    My attempt:

    #include <stdio.h>
    #include <stdlib.h>
  17. Replies
    4
    Views
    2,197

    @laserlight @Tibo-88: Thanks for quick revert. It...

    @laserlight @Tibo-88: Thanks for quick revert. It was not typo; I was flummoxed seeing expression "x<=y" in ternary operation. But thanks for clarifying.
  18. Replies
    4
    Views
    2,197

    Simple ternary operation baffling me

    #include <stdio.h>
    #include <stdlib.h>

    inline int min(int x, int y) { return x = y ? x : y; }



    int main(int argc, char** argv) {

    int x = 1;
  19. Thanks for the help everyone. I have managed to...

    Thanks for the help everyone. I have managed to get some output from the program. It helped me clear some concepts.


    #include <stdio.h>
    #include <stdlib.h>

    int main(void) {
    const char...
  20. Thanks for the heads up. Basis your input I've...

    Thanks for the heads up. Basis your input I've tweaked the code:


    #include <stdio.h>
    #include <stdlib.h>

    int main(void) {
    const char msg[15] = "blueberry";
    int c;
    int s[15];
  21. Unable to pinpoint my mistake for a seemingly simple K&R exercise.

    I am trying to work on a problem mentioned in K&R book (Excercise 2-4).



    I am not writing a separate function, I am trying to achieve squeeze(s1,s2) by writing the code in the main program...
  22. How to use a function that doesn't return a value in main()? Is it even possible?

    I am learning C with a generous help from K&R book (and internet of course). I need some assistance in understanding as to how to use following function in my main program.


    void strcat(char s[],...
  23. Thanks :)!

    Thanks :)!
  24. Thanks for that detailed explanation on Function....

    Thanks for that detailed explanation on Function. I didn't say multiple values will be returned. Ok...at the risk of sounding absolute pinhead, here's what I understood:

    Main program calls...
  25. Thanks for taking out time for the explanation. ...

    Thanks for taking out time for the explanation.

    At this moment I don't want to return multiple value. I am just intrigued why multiple value isn't getting returned. As per my understanding since...
Results 1 to 25 of 55
Page 1 of 3 1 2 3