Recent content by carl123

  1. C

    Reverse a String in C - Solve Segmentation Fault

    Thanks for your reply. Pls could you explain further. Not sure what you mean
  2. C

    Reverse a String in C - Solve Segmentation Fault

    This is what I came up with but I keep getting segmentation fault whenever I run it in linux. Not sure why. Any help would be appreciated. Thanks #include <stdio.h> #include <string.h> #include <stdlib.h> int main(int argc, char** argv) { int i, childpid; for (i = strlen(argv[1]); i >=...
  3. C

    Comp Sci How to debug an infinite loop in a C++ program using fork gymnastics?

    This is what I did but I'm getting an infinite loop of the reversed string whenever I run the program. I don't know why #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> /* for fork() and getpid() */ #include <sys/types.h> #include <iostream> using namespace std...
  4. C

    Comp Sci Book Database Implementation C++

    I began by creating 2 classes. A book class and a course class that contains any necessary info about the book and course respectively class bookClass{ private: string theISBN; string thebookName; string thebookAuthor; double thebookCost; int...
  5. C

    How to Implement a Salami Memory Allocator in C?

    Thanks for the input everyone. All your suggestions have given me a clear idea of what I'm supposed to do. Appreciate it
  6. C

    How to Implement a Salami Memory Allocator in C?

    Salami Allocator In this warm-up submission you will write a totally trivial allocator: The function init allocator() reserves a given portion of memory for the allocator. Every call to my_malloc() cuts off the requested amount of memory from the remainder of the reserved memory. The call to...
  7. C

    MHB Assign a pointer to any instance of searchChar in personName to searchResult.

    Ok, I was able to figure it out. I added this: searchResult = strchr(personName, searchChar); and it works. Thanks!
  8. C

    MHB Assign a pointer to any instance of searchChar in personName to searchResult.

    #include <iostream> #include <cstring> using namespace std; int main() { char personName[100] = "Albert Johnson"; char searchChar = 'J'; char* searchResult = 0; /* Your solution goes here */ if (searchResult != 0) { cout << "Character found." << endl; } else {...
  9. C

    MHB Vector Field Formula for Graph in [-2,2] x [-2,2]

    Their cross product is equal
  10. C

    MHB Vector Field Formula for Graph in [-2,2] x [-2,2]

    if the denominator is 0, the formula will be undefined. What does that say about the graph? Also, when I found the cross product of [-2,2] and [-2,2], I got 0. Does that mean, there's no field that resembles the graph? Thanks.
  11. C

    MHB Vector Field Formula for Graph in [-2,2] x [-2,2]

    where x = 1 is a singular point, the denominator will be 0 then.
  12. C

    MHB Vector Field Formula for Graph in [-2,2] x [-2,2]

    Will it be f (x,y) = f (-2,2)?
  13. C

    MHB Vector Field Formula for Graph in [-2,2] x [-2,2]

    Give an example of a formula for a vector field whose graph would closely resemble the one shown. The box for this figure is [−2, 2] x [−2, 2]. Not sure where to start.
  14. C

    C/C++ Create a C++ logic calculator (T/F) using a recursive descent parser

    I'm supposed to make a simple logic calculator based on the following requirements: 1. The user can use either capital or lower case 'T' and 'F' in their expression. 2. Use either a ';' or '=' to indicate the expression should be evaluated immediately. 3. The program should not exit when it...
Back
Top