rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Keep a count with the target_strings (terms) in a map. If you get results from a search term, you take pResults + 1 and search again, adding to the count for that term, looping with this until strstr() returns null. Then you go to the next term, and start again. So, this can be done in a dual nested loop, the outer iterating through the map of terms, and the inner searching for that term until null is returned by strstr(). Try this, and show what you have done for that algorithm.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The strstr() function returns a pointer to the start of the results string that matches the target string in the source string. Since they are both pointers, you simply subtract the source string address from the results string (pointer math) and you get the offset of the target in the source in bytes. IE, this will be the position of your target. This is the most efficient method, and one I use regularly with log file data in order to extract the bits I am interested in. See the man page for the strstr() function. If you need a copy, let me know and I'll post it here.

Here is an example:

char* pStart = source_string_address;
char* pTarget = target_string_address;
char* pResults = strstr(pStart, pTarget);
// Assuming that pResults is not null
ssize_t results_location = pResults - pStart;
Gà_1 commented: Seem that your method is for counting (find pos) at characters. Can you please expain more about how this method work at counting at words(in OP's pb) +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
  1. Read the data file into a single string, replacing new lines with spaces.
  2. For each string in the query file, use strstr() to find the position in the string from the data file.
  3. Done.
Gà_1 commented: Much better than my idea. But can you please explain more how can we find "position by number" using strstr(). +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Read this tutorial on random number generators and you will understand better how all this works: http://www.phy.ornl.gov/csep/CSEP/RN/RN.html

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Read this tutorial on random number generators and you will understand better how all this works: http://www.phy.ornl.gov/csep/CSEP/RN/RN.html

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

So, is there a question here? Or are you just showing off?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Sorry, but I haven't used OpenMP for about 20 years... Try the OpenMP user forums, assuming there are some. FWIW, OpenMP is good to distribute computations over multiple discrete systems, but given today's multi-processor, multi-core systems, threads work a lot better, at least up to a point.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

And your problem is? From your code, when the program ends, the destructor for class A should be called for each instance, generating something like this:

X=30,Y=40
X=10,Y=10
X=20,Y=50

Note that the output should be in reverse order of their declarations. This is what my Linux system shows from your code. This is because the destructors are called as the stack unwinds, last to first automatic variable.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Make effort. Post code. Post errors and problems. Not doing your homework for you, as per AleMonteiro.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Then to do that backwards:

    for (int i = value.length()-1; i >= 0; i--)
    {
        char currentChar = value[i];
        // do something with the char if you like
    }
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Actually, if your PATH environment includes the cygwin bin directory, then you should be able to run vi (vi.exe) from the command line. It should start up the cygwin services so it can run properly. I think I did that once upon a time, but so long ago I can't be sure (senior moment)! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, you should make a class for the food, and some if its properties would be things like you describe, such as health benefits, other foods that compliment it, etc. Then, using class methods, you can call up this information for a specific food instance in the main menu, or elsewhere.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

So, what is your problem? What do you think it needs to make it "better"?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is not enough to go on. Are these sensors built into your computer? External sensors with some sort of network connectivity? What? Have you contacted the sensor manufacturer's web site for libraries/api's and such to communicate with them, or even to get their technical specifications?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Please read the terms of service/use for these forums. We do not do your homework for you. When you have written the code to solve the assignment, and you are having errors or problems, then post it here and we may be able to help.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is a cross-platform build. You will need the GCC cross-platorm tool-chain to build this code, and DO NOT try to install the binaries on your Apple system unless you want "bad things" to happen! I build ARM binaries (kernel, etc) on my x86 Linux system frequently. Then, I move them to my ARM development system, test them out, and build the local applications in that environment directly.

And what exactly do you mean by "the program tag in the Makefile"?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This is a common compiler issue with new programs. If you intend to use that variable in the future, then just comment it out for now if you want to make the compiler to shut up. :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

One last question. Does it shut down after 15 minutes of user inactivity? Does it keep running if you keep "diddling" the system and running programs? If either is the case, then it has to be some obscure power configuration setting, at least that's what it would seem to me. If not, then I would agree with JorgeM that it may be a hardware issue.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

On Windows systems, Cygwin provides a Linux-type command environment with all the usual tools, including GCC compilers, bash shell, c-shell, and such. It works very well. I used to use its xorg X-Windows server in order to run X applications on remote servers that I had connected to with ssh or Putty (using the -X option to forward X-Windows protocol messages to Cygwin).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Most current 64-bit processors can run either 32-bit or 64-bit operating systems. As noted, a 32-bit one can only handle about 4GB of RAM whereas a 64-bit one can handle about 4 billion times that (in theory). In any case, you should run a 64-bit OS on a 64-bit processor. Most can happily run either 32-bit or 64-bit applications equally well. This includes 64-bit Windows as well as Linux/Unix systems.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I first started using Unicode back around 1989-1990 before it became a standard in order to support our Korean customers and provide help and other system messages in Hangul. Not simple! We contracted with another company that had already created the code to deal with this stuff - "wide" characters in C/C++ didn't yet exist at that time! In the end, it worked out well as the company we contracted with had a lot of experience with far eastern languages such as Chinese and Hangul. It was still a difficult process to provide real internationalization of text.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Also, your app can talk to a web server running PHP, which can easily access a MySQL database. In any case, you DO NOT want to run the database on your mobile device - it would quickly bring it to its knees!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

So, post your C code and I can probably help you solve this conundrum. I have been using XML and C/C++ for over 15 years.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

My advice? Just build optimized code and strip it before shipping. Trying to make it impossible to reverse engineer is a waste of time and resources. Yes, you could encrypt it, and require a proprietary key to decrypt it as it is loaded into memory, but once in memory, it is still vulnerable. We tried this once in the past, and the results, while pretty secure, was a serious PITA and we dropped it PDQ. That code runs most of the semiconductor, flat-panel display, and disc drive plants world wide, and we never in 20 years have seen anyone try to "steal" the code. It just isn't worth it!

If you have something really unique and solves problems in non-obvious ways, then patent it. That's the best protection for really original work. I know, I have one for adaptive systems as sole inventor. That patent is currently owned by Applied Materials, the 800lb gorilla of semiconductor equipment and software.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Scheme is basically Lisp. Sounds like you need to do some more study here. This may not be school work, but it looks a lot like homework for a course you are taking, even if an online one. Do you know how to write a recursive Scheme function? That is what you need to do for the fib() function.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

How you do it depends upon your operating system - Windows or Linux. It is time for you to do some research. It isn't too difficult, but in order for data to get to the correct computer this needs to be done. If your modem were attached to a router, this would not be necessary, but since it is attached to your computer, then you need to enable routing on your computer.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

@Slavi - yes Linux has its malware, mostly targeted at commercial enterprise systems, but it is much more difficult to pwn than Windows for one simple reason. When you set up a Windows system, the default user is given administrator privileges by default - no password required to get admin access. This is not the case with Linux. For root access (and many systems these days disallow root logins), you either need to su to root, or have sudo privileges, which still requires (by default - but this can be overridden if you know what you are doing) your password to get such access. Web servers are still a security weak point, and if people are going to host a web server they really need to be careful. As far as normal user systems are concerned, this is generally not an issue.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Check with Sony. And in the future, DO NOT buy Sony products! Once upon a time, they were great (I still have Sony audio tape recording and minidisc products), but they have become so consumer unfriendly that I can no longer support the company.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

This may or may not be relevant, but there are viruses / malware that can be installed in an onboard disc controller. Since whenever you attach the drive to your system everything goes "sideways", I have to wonder if either the drive is seriously farked up, or you have one of these rather nasty viruses. My advice now would be to replace it with a new drive. Hopefully, if it is a virus, it hasn't infected any of your other devices.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Yeah. You're busted, with one of those "We are the authorities and we have detected your illegal activities. Pay us a fine or you'll go to gaol!" viruses. Time to re-install your operating system, or better still, move to Linux where this sh!t doesn't happen.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

For Windows systems I use ClamWin (ClamAV on Linux). It is free, open source, and the basis for most industrial strength AV appliances out there. It doesn't do on-load scanning, but can scan files, as well as memory. I think it can do boot sector scanning as well, but I'm not 100% sure of that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Please don't make multiple identical posts. Not good forum etiquette, plus it makes it difficult for people to collaborate when the answer is non-trivial, as this one is.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What kind of shell? Windows shell? Linux/Unix bash, korn, csh, sh? What?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You would probably need to set up routing in the computer the modem is attached to. Also, you need the modem's IP address, which if it is dynamic (not a static address) may be a problem. Check with your ISP about this.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What do you mean by "not working hardware". Are you speaking about the computer system itself, or do you mean the disc. If the disc is still functional, data should be retrievable. I remove the disc from the system, put it in a docking bay (either eSata or USB), mount the file system(s) from a Linux computer, and copy the data to another external drive, such as a thumb drive or other such device.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

In the first case, 12.345 is probably being decoded as a double. In the second case, the variable A is a float. Welcome to the world of floating point numbers and rounding errors!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you have a recovery partition, you may be able to fix it. In any case, you need to scan the disc for hardware failures (too many bad sectors). It may be that the disc itself is fubar (fouled up beyond all recovery).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You aren't providing enough information. What kind of file? What did you do to "extract" the data? What is the source of this file and data?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Ask Microsoft? They do have user forums where you could ask this.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

@XP78USER - the /all flag should not be necessary to find the gateway address. What it will do is generate a lot of confusing data for a new user. :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What errors do you get? Does your system allow you to access the pendrive? These devices are generally factory formatted with a FAT file system which can be read by Windows, Linux, or Apple system. If you cannot access it, then it is likely a problem with your system software. I used to get this all the time with Windows 7 and had to remove all the USB devices from the device manager, and then reboot the system so it would reload the drivers and such. This was a regular PITA that I, and others, had to go through.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

No problem. New posters often make that mistake. The biggest problem with multiple posts is that one person will answer one, and another person will answer another. That dilutes the amount of help you will get since we can work off the comments and posts of others to get you the best results.

So, you are using this xml schema in a C program? Then am I correct to assume that this error occurs in the program? Can you post your code here that uses the XML file?

BTW, here is your code indented:

<xs:schema>
    <xs:simpleType name="nameType">
        <xs:restriction base="string">
            <xs:minLength value="1" />
            <xs:maxLength value="20" />
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="information">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="personal" maxOccurs="10">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element type="nameType" name="name"/>
                            <xs:element type="nameType" name="surname"/>
                            <xs:element type="nameType" name="age"/>
                            <xs:element type="nameType" name="postcode"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="school" maxOccurs="10">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element type="nameType" name="maths"/>
                            <xs:element type="nameType" name="english"/>
                            <xs:element type="nameType" name="physics"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

@javedkalabagh - please don't hijack other people's threads. Not good netiquette. Start your own thread to get help with learning C++.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Again, please DO NOT double (or triple) post in these forums. Remove this instance please. I have already answered one of these.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Please do NOT double post! Remove this one, please.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I assume there is a start node for <xs:schema>? Also, please properly indent the nodes. It helps to find such problems. In any case, this should be ok. What happens if you take the maxOccurs parameter out of the elements?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Check memory usage to see if your system may be hitting the virtual memory swap space.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Part of your problem is that you are using the same name for the global Numero_de_Materias as well as the argument name for a number of functions. DON'T DO THAT! use different names. This is why I try to indicate that a variable is global with a leading g_Name or static with s_Name. That will keep things clean. If you want to continue this discussion via private mail yo puedo hablar espanol con fluencia.

That said, I haven't analyized the code enough to know why it is failing for you as yet.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Here is the wikipedia article on it. It may help you understand what to do: http://en.wikipedia.org/wiki/Bucket_sort

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Sorry, but we don't do your homework for you. Read the terms of service for this site for more information. YOU write the code, test it, post it here for help when you get errors or incorrect behavior that you cannot solve, along with the errors and incorrect behavior that you are getting.