Search:

Type: Posts; User: BigFish21

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    3
    Views
    1,740

    appending a number to string?

    How do I append a number to the end of a string (and get a string back)? For example, I want to run a for() loop similar to: for(i = 0; i < num; i++), and for each pass through the loop I want to...
  2. Replies
    4
    Views
    2,553

    How would you do this using iterators? I need to...

    How would you do this using iterators? I need to learn how to do it this way, I think this is what's confusing me from most of the insertion sort examples I've seen using arrays.
  3. Replies
    4
    Views
    2,553

    Insertion sort problem...

    I want to use insertion sort to sort a vector containing some classes. Each class has a string name variable like this:


    class myClass {
    string name;
    ...
    }

    I want to sort the vector by...
  4. use an iterator

    use an iterator
  5. Converting a string of words into correct cases

    Let's say I have a string s:

    string s = "How are YOU doING toDay?"

    I want to convert this string so that only the first letter of each word is capitalized (so I want it to be: "How Are You...
  6. Replies
    9
    Views
    2,003

    vart, that works! thanks. Just one more question...

    vart, that works! thanks. Just one more question about copy constructors in general: You can specify additional parameters for a copy constructor (in addition to the reference to same class type) as...
  7. Replies
    9
    Views
    2,003

    Well bClass[] is actually dynamically allocated...

    Well bClass[] is actually dynamically allocated with
    bClass[i] = new aClass(arg1, arg2); looping through a for loop in a separate function (arg1 and arg2 are arguments to the constructor for...
  8. Replies
    9
    Views
    2,003

    Copy constructor question

    Suppose I have a class like this:

    class aClass {
    char *ptr; // random variable, not important
    int time;
    aClass *bClass[5];
    public:
    aClass();
    ~aClass();
    aClass(const aClass&...
  9. Replies
    25
    Views
    4,138

    Ok, I've encountered another problem in this...

    Ok, I've encountered another problem in this program. So far I've implemented mkdir() and ls() that both work, however I've been trying for the past day to be able to do this: When the program first...
  10. Replies
    25
    Views
    4,138

    Ok I got this to work!: ...

    Ok I got this to work!:

    (*(*funix).currentDirectory).subDir = (Directory**)malloc(3*sizeof(struct Dir *));
    funix->currentDirectory->subDir[0] = (Directory*)malloc(sizeof(Directory));
    ...
  11. Replies
    25
    Views
    4,138

    Ahh ok, so I managed to dynamically allocate...

    Ahh ok, so I managed to dynamically allocate subDirs, but I'm getting an error when trying allocate subDir.name:

    (*(*funix).currentDirectory).subDir = (Directory**)malloc(3*sizeof(struct Dir *));...
  12. Replies
    25
    Views
    4,138

    Ok got it. Now with a question for actually...

    Ok got it.

    Now with a question for actually creating directories with function mkdir():
    When the user enters a mkdir command, I call the mkdir() function:

    void mkdir(Funix *funix, int...
  13. Replies
    25
    Views
    4,138

    Ok so this isn't a structs question, but I've...

    Ok so this isn't a structs question, but I've moved on to actually getting a command from the user. I want to store the number of arguments and also how many arguments. This is what I have now in...
  14. Replies
    48
    Views
    11,813

    Why wouldn't that work? You can do something like...

    Why wouldn't that work? You can do something like this:
    char *str;
    while (str != NULL) {
    str = strtok(line, ":"); // <- this will store "somefile"
    str = strtok(NULL, ":"); // <- now str will...
  15. Replies
    25
    Views
    4,138

    Thanks Elysia, for the casting I learned to not...

    Thanks Elysia, for the casting I learned to not cast it either, but for this assignment we are supposed to compile it with g++ (I'm not sure why exactly..) and I always get an error if I don't cast...
  16. Replies
    25
    Views
    4,138

    Oh I see. I realize I made a mistake in my...

    Oh I see. I realize I made a mistake in my Directory struct though, the Permissions struct should not be defined in it like that, instead (I think) I want a pointer to an instance of the Permissions...
  17. Replies
    25
    Views
    4,138

    Hm yes that does seem to work, what does it do...

    Hm yes that does seem to work, what does it do exactly? Is there another way of doing this? I only remember learning a little bit about the -> operator a while ago, don't remember much now. thanks
  18. Replies
    25
    Views
    4,138

    Oh, I see, stupid mistake. Thanks So it works...

    Oh, I see, stupid mistake. Thanks

    So it works now when I want to access the Funix struct (i.e. (*funix).umask = 666), but I still can't access the Directory struct. I tried this:
    ...
  19. Replies
    25
    Views
    4,138

    So if I understand you correctly I first have to...

    So if I understand you correctly I first have to do this in init()?:

    Directory *currentDirectory = (Directory*)malloc(sizeof(Directory));
    (*currentDirectory).name = (char*)malloc(sizeof(char));
    ...
  20. Replies
    25
    Views
    4,138

    Oh my bad, yeah it is Funix sorry. So I first...

    Oh my bad, yeah it is Funix sorry.

    So I first do Directory *currentDir? How would I access it? (*funix).currentDir.name? I havent seen that before, that's probably wrong.

    thanks!
  21. Replies
    25
    Views
    4,138

    Structs question

    For a programming assignment I have the following two structs: (sorry it's a bit long!)


    typedef struct Dir
    {
    char *name;
    struct Dir** subDir;
    struct Dir* parent;
    struct
    {
  22. Replies
    3
    Views
    2,044

    struct within a struct?

    For this program I have to write it seems I have to use a struct within a struct. I tried simply doing this:


    typedef struct
    {
    ...
    typedef struct
    {
    ...
    ...
  23. Replies
    4
    Views
    1,409

    Oh I see, yes rooms is declared "Room *rooms" in...

    Oh I see, yes rooms is declared "Room *rooms" in main(). thanks
  24. Replies
    4
    Views
    1,409

    Something I don't understand...

    In an example program my professor gave me that reads data from a file about rooms. For example the data file reads:

    Bill Mueller
    129450.93 4
    2:300.5:Living Room
    1:107.0:Bedroom 1...
  25. Replies
    2
    Views
    36,354

    What does fread() return at end of file?

    I want to use fread() to read a binary file containing Passenger structs like this:


    typedef struct
    {
    int ID;
    char first_name[15];
    char last_name[15];
    int flight_nums[4];
    }...
Results 1 to 25 of 39
Page 1 of 2 1 2