Search:

Type: Posts; User: space-oddity

Search: Search took 0.00 seconds.

  1. Replies
    19
    Views
    2,856

    Thanks for your help guys, I played around with...

    Thanks for your help guys, I played around with your code adak and realised I was getting the bad output due to using the isspace function.. why was that the cause? The description of it in the man...
  2. for practice? the poster said it was an exercise

    for practice? the poster said it was an exercise
  3. chucked this together, not everything is declared...

    chucked this together, not everything is declared but should give you an idea how to do it..



    int i = 0;
    int numAppearances = 0;
    while (string[i] != '\0') {
    int j = 0;
    while (j <...
  4. Replies
    5
    Views
    1,843

    haha i like those answers iMalc

    haha i like those answers iMalc
  5. Replies
    19
    Views
    2,856

    After doing a bit of study, I realised that the...

    After doing a bit of study, I realised that the code might not be working because im incrementing text, ie. text++, when text is declared to be a const pointer. Is this allowed? If not how can I...
  6. Replies
    19
    Views
    2,856

    i fixed up that statement, but the output is...

    i fixed up that statement, but the output is still exactly the same.
    more help?
  7. Replies
    19
    Views
    2,856

    just to make sure, *text == 0 and *text ==...

    just to make sure,
    *text == 0
    and
    *text == '\0'
    are exactly the same?
  8. Replies
    22
    Views
    3,201

    ahh yes that's right, \\ instead of "\, i knew...

    ahh yes that's right, \\ instead of "\, i knew that but for some reason muddled up. i think i was thinking of the case when you want to output doubequotes and you write \" my mistake.
    sorry for the...
  9. Replies
    19
    Views
    2,856

    oh okay, i'd been assuming that text != NULL...

    oh okay, i'd been assuming that
    text != NULL
    and
    *text != '\0'
    were the same.
    thanks.
  10. Replies
    22
    Views
    3,201

    im not sure why that's happening sorry, you'll...

    im not sure why that's happening sorry, you'll have to wait for someone else to reply on that
  11. Replies
    22
    Views
    3,201

    actually you don't have to use strncmp if you're...

    actually you don't have to use strncmp if you're just comparing for equality to one letter (but you don't know whether it's less than or greater than if it isn't equal). you can do something like:
    ...
  12. Replies
    19
    Views
    2,856

    someone?

    someone?
  13. Replies
    22
    Views
    3,201

    missing an endquote? if you want to print a...

    missing an endquote? if you want to print a backslash you just put one doublequote before it:

    printf("Printing a backslash: "\ Done.");

    you want to compare the whole word with just one letter?...
  14. Replies
    22
    Views
    3,201

    To print a backslash you must put a doublequote...

    To print a backslash you must put a doublequote before it:


    printf(""\");


    The strncmp function can be used to compare the first n characters of two strings and returns 0 if same, <0 if less...
  15. Replies
    19
    Views
    2,856

    I had another try at it, starting over from...

    I had another try at it, starting over from scratch, after trying to understand pointers better and so I utilised them more here. Unfortunately this time the function, when run, just continually...
  16. Replies
    19
    Views
    2,856

    looks like the greedy algorithm is the same as...

    looks like the greedy algorithm is the same as what im trying to do with my code.

    if i use dynamic memory allocation for currWord there's no possibility of a memory leak when a program using the...
  17. okay, thanks. so the code at the bottom of the...

    okay, thanks. so the code at the bottom of the first post is the way to go?
  18. Replies
    19
    Views
    2,856

    i want to trim it at words

    i want to trim it at words
  19. what, i can't modify it, meaning i can't use my...

    what, i can't modify it, meaning i can't use my function on it?
  20. Replies
    19
    Views
    2,856

    But doesn't while (isspace(text) == 0) {} only do...

    But doesn't while (isspace(text) == 0) {} only do the things while it [I]isn't a space? (as opposed to == 1 which would be while it is a space)
    So it couldn't be both?

    I used char...
  21. Replies
    19
    Views
    2,856

    No ouput from my function, please check?

    Hi, I wrote a c file to output text, making sure it doesn't go over a maximum width:



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

    #include "printer.h"
  22. i just edited my code and posed the question a...

    i just edited my code and posed the question a little differently
  23. Question about my trim function and pointers

    Hey, I wrote this function to eliminate all leading and trailing spaces from a string..



    void trim(char** str) {
    char ptr[strlen(str)+1];
    int i = 0, j = 0;
    while (isspace(str[i]) == 1) {...
Results 1 to 23 of 24