rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

It depends upon the operating system. There are a couple of problems here, besides the OS issue, what have you tried so far? And is this a school exercise, or is it work-related? So, show your work.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

So, what is the output from preprint() and iprint()?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Put your entire HTML section, along with the PHP, properly formatted into a code block. This is unreadable without a lot of effort, and you aren't paying me enough to take the time!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

In any case, it isn't easy to traverse a queue. You can pop the entries out and then push them back, or push them into a temporary queue where you then pop them out and push them back into the now empty main queue. If you don't have to use a queue, then I would suggest using a vector. That is easily traversable. Ditto a deque. Go to http://www.cplusplus.com/reference/ for more information about all of this stuff.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Sorry. I'm not going to do your homework for you. That said, for #2 you can get the number of elements in the queue with the size() method. IE:
cout << "Total customer in waiting list: " << dec << qnum.size() << endl;
That's as far as I'm going to help you until you write the rest of the code to the best of your ability.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Lovely! MIPS assembler. I would suggest writing it in C and then have the code compiled into assembler so you can see what a reasonable assembler encoding would be. FYI, I haven't messed with MIPS code for probably more years than you have been alive, so I don't remember much! I don't write much ARM or x86 assembler either unless I am working on some architecture-specific linux kernel code, and then as little as possible!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Are you sure the mytree print lines are not reversed in order?

System.out.println("-------------Pre-order------------------");
mytree.iprint();
System.out.println("---------------In-Order-----------------");
mytree.preprint();

Anyway, please show your input, and your output.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

According the the php documentation, there is no function mysqli_fetch_row. There is mysqli_stmt_fetch. You need to review the documentation more closely. Look here: http://php.net/manual/en/mysqli-stmt.fetch.php

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Ok. Assuming I have misjudged you, a lot of compilers these days, such as Visual Studio, employ what is called something like address randomization in order to make it more difficult to corrupt software. IE, the address of something like your array will not be at the same relative location every time it is compiled or run. You might be able to insert a tag in the code that will allow you to pinpoint where your target address really is. IE, doing something like allocating a bit more space for the array, and then insert the tag at the end of the array. Where you find your tag, you can then compute there the beginning of the array would be. Let's say you want a char array of 100 bytes (including terminating null byte), and you are using a tag of "xyzzy". Then, allocate an array of 106 bytes and append the string "xyzzy" (including terminating null byte) at &array[100]. I haven't done this myself, so this is a "theoretical" approach, but it should work.

To continue, in your example, you have defined an unused string on the stack. The compiler will, optimizations notwithstanding, not include it in the image. You need to do something with it in your code. Also, it is on the stack. Put it on the heap in an extern variable using a malloc/calloc or strdup call, and then do something with it. You might be able to declare it as an extern without allocating the …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

So far, so good. Try some more web searching, especially studying the ANSI terminal control sequences, which provide just what you need. FWIW, I don't give obvious answers to questions you can deal with yourself with a very little effort!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This sounds a lot like a means to pwn an application. Please take your attempts to subvert application security elsewhere!

MandrewP commented: You are wrongly judging me. I'm not trying to do anything illegal or immoral. I just thought that there might be a means provided within the compiler +6
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What you are saying makes zero sense. What exactly is your problem? You have set a boolean (true/false) variable to false. You have set an integer variable to 90.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

My brother-in-law had to do this. He restored Win7 from his recovery partition, and disabled automatic updates. We were able to recover his data. In any case, the update to Win10 didn't seem to have affected the recovery partition. Have you tried that yet?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You don't say if you are using a video or text console library or if the output is just ascii text in a terminal / console. Also, I assume this is C or C++. So, please show your code, and then we can help you better. Yes, you can (and probably should) use a for() loop here.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You haven't declared/implemented your functions that handle the computations and display output. Where is the functions.h header and functions.c code? You will also have to #include "functions.h" in the ela010task2.c file where main() should be. In addition, main() should be int main(void). There are other likely problems with your current code but this will start.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I run Linux almost exclusively and have not had this problem. What versions of Linux & Firefox are you running?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As @cereal said, the old MySQL API has been deprecated. DO NOT use it! Use the MySQLi API instead. You can find details about that on the php.net web site.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Yes, what nullptr said. The << operator is the output operator, but cin is an input stream so it won't have an operator<<().

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Do you have ANY idea what your are doing? Are you trying to use std::deque for your code? Are you trying to "roll your own" version? See this: http://www.cplusplus.com/reference/deque/deque/

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Why does the Runway class have instantiated public member variables for Plane, landing and takeoff? It appears to me that you have not analyzed your use cases properly. Other beginner C++ issues - you have no default constructor, no copy constructor, or assignment operator. If not needed, then declare them as private, but don't implement them. If you don't do that, then the compiler will happily construct them for you, with unhappy results...

So, my analysis of your code is that you are just getting started in understanding C++ programming and need to do a lot more study before you are prepared to accomplish this assignment properly. I am a senior systems software engineer (contractor) at a tier-1 global company, and my predicessor was about at your level of C++ expertise. I have spent the past month sorting out his errors... And the company is paying me over $60 per hour to do that...

All of that stuff aside, do the most with the least. Each class should only contain variables that are relevant to their existence. You may have a Plane pointer to the next or current landing/taking-off entity in Runway, but they will NOT be fully instantiated members of the class object. GAH!

All of that said, as Suzie asked, what exactly IS your problem (other than the obvious)?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Is the modem also a router/switch/Wifi access point?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What operating system are you running? Windows, or Linux?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, I would need to see the incoming http request to determine why it is "malformed". FWIW, once we were satisfied that the php code was working correctly, we could deploy it in a real web server (Apache) without problems, but you need to tell Apache that it needs to listen on the new port.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As another point, Windows is MUCH more susceptible to virus infections, especially of the web page infection variety. Linux is much more secure in that regard because of how it deals with file system permissions and such, which is why most serious web sites use Linux (usually some variety of Red Hat Enterprise Linux such as RHEL, CentOS, etc) for their web hosting. We used CentOS exclusively at Nokia Mobile Phones (before being taken over by Microsoft) and we NEVER had a problem of that sort, and we were dealing with over 100 million users and billions of connections / pages served each day.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
  1. Always get your kids their own computers - let them figure out how to fix it when they are pwnd.
  2. NEVER let your kids use your computer. GoTo #1...
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A lot of these "end-of-life" issues are caused by bad capacitors. If you want to keep the system, take it to a reputable repair shop, or send it in to HP or an HP repair depot to fix. You should be able to find how to do that on the HP web site.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you run "php --help" you will see that one of the options is to run PHP directly as a web server (no LAMP stack required), which is the "-S <addr>:<port>" option. IE, you can do this directly in PHP by starting it with the correct address and port information. You should then get the data directly. Try this

php -S 1.2.3.4:31334 gettcp.php

directly from the command line. You can do it in the shell. I don't think you have to run it as admin. I used to do this to test my PHP code at Nokia. In some cases, we would just use it as-is and not bother with Apache or Ngnix.

You can also run it in the background, but that isn't necessary.

phpkoder commented: Thanks, It would be great if you check my new answer +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

No, I simply said that doing so is not safe coding practice. In itself, that is workable, but before you try to access the contents of the pointer (the real integer), you need to be sure that it isn't null. When you allocate those structures you should use calloc() and not malloc() as that will clear the memory, making sure that both pointers are set to NULL and not some bogus address. Consider this code:

struct list
{
    struct list* next;
    int* data;
};

struct list* head = malloc(sizeof(struct list));
head->data = malloc(sizeof(int));
*head->data = 1;

/* so far ok. */
head->next = malloc(sizeof(struct list));

int i = 0;
for (struct list* plist = head; plist != NULL; plist = plist->next)
{
    if (plist->data != NULL)
    {
        printf("data at element %d == %d\n", i, *(plist->data));
    }
    i++;
}
/* The first element (0) will print just fine.
 * Accessing data in the second element will,
 * or even accessing the list element itself
 * will likely result in a SEGFAULT.
 * Changing the malloc's to calloc() calls
 * will let this code run to completion.
 */
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Please post your code using the </>Code option in the editor. It is basically unreadable as it is, unless you really want to enter in the "Obfuscated C Contest"... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Can't fix the title, but there are a number of issues in your code, and I expect you could find them after a nice drink and good night's sleep... :-) Anyway look at your array indices in cat(). Also, instead of malloc'ing everything and then copying the data, try that nice function strdup(). It will take care of the allocation and copying for you. Also, in your declaration of strings_line_tokens[], you are only setting one element, and you only populate the 0th and 1st elements with real strings in main, yet in cat() you are calling strcpy on elements 1, 2, and 3. It should be 0 and 1 as 2 and 3 will either be null pointers, or just bogus data, depending upon your compiler. In any case, this is where things go belly up, or as we say in the business, you let the smoke out!

So, apply these suggestions to your code, and repost after you have fixed it. I'll be happy to look again then.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There are more choices for Linux. Besides Apache, there is Nginx, and other web servers. Many of those also have Windows versions, but not so much because of the "locked down" nature of Windows.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

float x = 10.0;
float y = 2.0;
float z = x/y;

System.out.printf("x == %f, y == %f, x/y == %f\n", x, y , z);

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Here is the root page of those articles and tutorials: http://www.phy.ornl.gov/csep/
It is a really great bunch of tutorials and articles on computational physics.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The srand() function sets the random number generator "seed", which is used to generate random numbers with the rand() or rand_r(). The latter one uses the supplied seed value and is a weak generator. It is considered obsolete today. If you want a more "space age" random number generator, then use srand48() to seed the generator, and drand48() to get your random values. It uses what is call an LCG (linear congruential generator) with 48-bit math to get better distribution of your random values. Here is a link to a great tutorial on random number generators: http://www.phy.ornl.gov/csep/CSEP/RN/RN.html complements of the US Government and Oak Ridge National Laboratory - our tax dollars at work!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Have you tried another vga cable? Or another vga monitor? Did you use the same cable on the PS4? If so, then your computer has a problem with the vga adapter or connector.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

It sounds like the video sub-system has failed. You may want to take or send it in for diagnosis and/or repairs. It may simply be a broken solder joint on the video connector which would be easy to fix. Without the unit in hand, I can't say much more than that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

PHP is, in my humble (or not so) opinion, a great framework for server-side web development. JavaScript, HTML and the rest are mostly client-side tools. If the specified code (PHP, JS, HTML) are properly secured on the server, then the chances of malware infections are greatly reduced. These days, security has an upper-seat to that of ease-of-implementation. Simple precautions can result in much more secure systems. Speed of delivery? A fast road to perdition, in my opinion. I'd rather take 2 more days to be sure that my code cannot be used to pwn my users' systems.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, you need to describe what areas are of most interest to you as a career. Java (C++ with training wheels, as is C# and such) is a good place to start to learn programming basics, algorithm implementation, etc. Most 1st class programmers I know are capable of programming in any number of languages - C, C++, Java, JavaScript, PHP, VB, C#, and others - the languages I have used in the past in my professional career include: x8048 assembler, x86 assembler, Fortran, Basic (many dialects), C, C++, Dibol, Cobol, SmallTalk, Prolog, PHP, PL/SQL, T-SQL, Lisp, JavaScript, Java, ... and more I can no longer remember... :-) When asked what programming language I use, I answer "YAPL". With a confused look on their face they ask "What is that?" Ans: Yet Another Programming Language. And yes, I am familiar with APL (Another Programming Language - very much math-oriented), but I have never used it professionally! My good friend Michael Beeson (chairman of the UC San Jose math department) uses it extensively.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Certainly! This is not uncommon. However, it would be preferable in your example to use a non-pointer-to-integer. Why? Because you don't have control over that pointer. The code that set it may delete it, then where are you? In SEGFAULT land! As a software developer, you need to think about this stuff, all the time! Figure that the users will do stuff that will bork the system. Your job is to minimize the possibility that their actions will compromise the system. This plays directly into security considerations as well.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As for your question: Is it right way to implement the same ?
can we delete the pointer which was never been allocated in constructor?

The answer to this is that when you assign an object to a smart pointer, it's ownership is passed to the smart pointer. Caveat. If the object is on the stack and not the heap, then you need to make a copy of it, otherwise "bad things" will happen! So, you may want to have another constructor that takes a reference to the object. When that happens, you can create a copy easily enough. The caller doesn't need to worry about it. The purpose of this stuff, and application development frameworks in general, is that the user of the framework should not have to be to cognizant of how the framework works. They should be able to concentrate on their domain and not worry about what is going on "under the covers". Example:

       SmartPtr(const T& theObj) : ptr(NULL)
       {
          ptr = new T(theObj);
       }

Or:

       SmartPtr(const T& theObj) : ptr(new T(theObj)) {}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There are a number of errors in this code. Nothing major, but a lot of things for you to think about...

    #include <iostream>
    using namespace std;
    // A generic smart pointer class
    template <class T> class SmartPtr
    {
       T *ptr;  // Actual pointer
    public:
       // Constructor
       SmartPtr(T* p = NULL) : ptr(p) {}
       // Destructor
       ~SmartPtr() { delete(ptr); }
       // Overloading dereferncing operator
        const T& operator*() const
        {
            if (!ptr) // throw exception
            else
                return *ptr;
        }
      T& operator*()
        {
            if (!ptr) // throw exception
            else
                return *ptr;
        }
       // Overloding arrow operator so that members of T can be accessed
       // like a pointer (useful if T represents a class or struct or 
       // union type)
       const T* operator->() const { return ptr; }
       T* operator->() { return ptr; }
    };

    int main()
    {
        SmartPtr<int> ptr(new int());
        *ptr = 20;
        cout << *ptr;
        return 0;
    }
  1. Your contents-of operator should have two methods. One is a const method that returns a const reference to the member. The other would be as you did, which is non-const. If it doesn't throw an exception, then you can set the value as shown in main(). See my additions/changes above.
  2. If you have the appropriate setter method, then you can create a pointer to the integer and set it accordingly, or if it already exists you can reset the value as specified.

So, your main problem is that you have not dealt with the possibility of a null pointer to …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you are running MySQL on your own server/host, then you can modify the config file and restart the server. I think 13 connections are the default. You can increase that in /etc/my.cnf with this line:

max_connections = <max-connection-count>

You will need to edit /etc/my.cnf and add this line, with <max-connection-count> set to a value that makes sense for your environment.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

And dealing with real-time systems, please DO NOT get me started on Rate Monotonic Analysis methods! :LOL:! If you do, you will be tortured with a VERY long lecture on the subject...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As an aside, many years ago (in the late 1980's) I did exactly what you are doing, to implement quicksort to deal with highly dynamic arrays of data. I would keep track of the last sorted size of the array, the number of items removed or added, and when the sum of those exceeded some pre-determined count, the array would be resorted. IE, new items were simply added to the bottom of the array. Removed items would result in the followning contents being moved up one element (memmove() is good for that - very efficient), and the old end-of-sorted element count decrement by one if the item was in that section of the array. Searches had to look using the old "end-of-sorted" elements value, and if not found, look from the "end-of-sorted" point to the actual end of the array. Not good for real-time systems, which was my domain back then. That is why I went to the insertion sort method. The time to insert an element was computable based upon the number of elements in the array.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

@Ivan_9. Quicksort and bsearch are two parts of the same whole. Quicksort uses bsearch algorithms to determine where to put the next element in the array. Knuth Vol.3 "Sorting and Searching" goes into this in detail. In any case, the common system qsort function will sort your array very nicely. You basically only need a comparison function to pass to the qsort() function, as well as some other elements, such as the address of the beginning of the array, the number of elements in the array, the size of each element, and a pointer to the compare function. Bingo, you are done!

If you have to "roll your own" quicksort function, then you REALLY need to understand what is going on here. Here is the Wikipedia article about quicksort. It is quite good. https://en.wikipedia.org/wiki/Quicksort

Personally, I prefer Knuth. :-)

FWIW, I have implemented these algorithms from scratch in C, C++, Java, and SmallTalk.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I try to stay as far away from Exchange as I can - that is what our IT staff is paid for. So, that is just my way of saying "I don't have a clue". That disclaimer said, it should be possible to move the data store to the external provider; however, I would certainly consult with their technical people as to the appropriate/best ways to do that. There may be caveats to consider that I am personally clueless about.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can disable tar's removal of absolute paths (including, but not limited to '/' and '../'). It does that so that when you extract the files from the tarball it doesn't overwrite stuff you don't intend it to. It will extract the files, by default, into the local directory where you run the command from - not where the tarball is. Overwriting this default behavior of tar is VERY dangerous can can easily bork your system, permanently! Better to extract stuff to the current directory (and DO NOT do that from the root directory, or as the root user!) and then move it as necessary. If you are the root user, it will preserve ownership and permissions of the extracted files and directories. Again, MAKE SURE you are not in the root (/) directory, or other sensitive places such as /etc, etc... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

PHP is an object oriented language based upon C++. It is most useful, and secure, when used that way. You save your HTML and JavaScript strings in class variables, and then output them when appropriate. DO NOT mix your HTML/JS code with PHP! That is a quick road to perdition.

diafol commented: Good advice +15
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is where a Google or DuckDuckGo search would be a good idea. A short search for "epub editing software" returns a lot of good options.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you have backup copies of your web pages and source code (you do, don't you?), then compare them to what is in the web server directory tree. You may have been compromised. See if there are differences. If you don't have secured backups (shame on you!), then you will have to do a visual inspection of the code. Stuff that was working yesterday and doesn't today usually indicates enemy action! Especially if you are the only person who has direct access to those files to change them!