Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I see it has html turned off (the default setting).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I copied/pasted the html code for my member badge into my vBulletin web site but it doesn't work. All I get is the html code and not the badge image. What's wrong?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It is better to pass the ofstream as a parameter instead of making it a global because globals are generally frowned upon. Pass by reference, you can't pass it by value.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What exactly is the problem you have? Are you trying to read the whole file into memory at one time? Or just read small parts of it?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Deposit $10,000.00 USD in my paypal account and I'll write it for you. :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ASTRONOMERS!

Yes, that's what I meant :)

, that event is called the Big Bang, it isn't a theory,

Ok, your the scientist -- prove it. Has anyone been able to see it with their own eyes? Its as much a "theory" as Creationism. I'm not saying Big Bang will never be proven, but it hasn't yet.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just because you attended a place of worship didn't make you a believer

Not far from where I live, out in the countryside, next to a church is a tavern (pub). I always thought that was amusing, go to the pub on Saturday night to get drunk then go to church the next morning.

Where do you see that science and religion, at least Christianity, can not always peacefully co-exist? There are only two things in the Bible that I think science has not and can not prove or disprove: (1) the existance of God, and (2) that God created the universe. The Bible just simply states that He created the universe, it says nothing about how He did it. Science has been trying to determine that for the last 2,000 or so years and has yet to figure it all out. I don't believe any more than anyone else that God played magician and said "Abracadabr", snapped his fingures, and poof! the universe was created. On the otherhand, according to astrologers in tv documdentaries I've seen the universe was created by the Big Bang theory and very very quickly. It went from something smaller than a molicule to an entire universe with a very short period of time.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The first thing I noticed while stepping (debugging) through your program is that you are pushing "." and ".." as well as other folder names onto the vector of files (see line 49). If the file is a folder then you don't want to do that.

Instead of main() passsing ".." to scan(), have main() call _getcwd() to get the current working directory and pass that to scan().

Then in scan(), the value of fullPath should just be the same as the parameter startDir

Here is the complete program I tested. Notice that I commented out a few things in main() that you may want to put back in. I didn't know what it was for su I just commented it out

#include <iomanip>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <ctime>     // ctime_s()
#include <io.h>          // _findfirst, etc.
#include <direct.h>
using namespace std;
vector<string> filesFound;

vector<string> scan( string const& filespec, string startDir, bool isRecursive )
{
    intptr_t hFile;
    _finddata_t fd;

    // fix directory name
    if( !startDir.empty() )
    {
        char last = startDir.back();
        if( last != '/' && last != '\\' && last != ':' )
            startDir += '/';
    }
    string findPath = startDir + filespec;
    string fullPath = startDir; //findPath + "\\";


    if( (hFile = _findfirst( findPath.c_str(), &fd )) == -1L )
    {
        cout << "No " << filespec << " files in current directory." << endl;
        return filesFound;
    }

    do {
        if( isRecursive &&
            (fd.attrib & _A_SUBDIR) &&
            fd.name != string(".") &&
            fd.name != string("..") ) …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 29: should be %d, not %s because newrep[ndigit] is a single numeric digit, not a string

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The loop is wrong

while( fscanf(...) > 0)
{
    printf ("Integer read = [%d]\n",i);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Duuh! I see it now.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The reason of this behaviour is that the readfile read the file until get NULL

I think you misunderstood. ReadFile() reads in binary mode, the same as fstream.read() or in C fread(). You tell it how many bytes to read and it will read that many bytes, or until end-of-file. ReadFile() doesn't do text reads like c++ getline() or fgets().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Try the new formatting help link

I'd like to see that link made a sticky somewhere so that we can refer to it easily.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your statement that # needs to be escaped when posting code. But then if the poster doesn't use code tags then its a problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

test

#include <stdiol.h>

end of test. # doesn't need to be escaped when used within ~~~ code tags

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It doesn't matter, C# and cli/c++ are close cousins so the solution to your problem is most likely the same. google for that error message and you will find more help

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

findPath+fd.name );

Line 5: Check the value of findPath, does it contain a trailing / or \ ? If not then you need to put one there. Also check if the file was opened: if( in.is_open() ) {

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Check the *.def file to make sure you exported that function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The "Link" control should work the same as in the old BB editor

Agree -- It is so clumsy to use that I don't use it at all any more but just post the link.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you google for that error message you will get some help, for example this link:

http://www.west-wind.com/weblog/posts/2012/Jan/13/Unable-to-cast-transparent-proxy-to-type-type

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ifstream in( );

line 36: Inside the parenthese you put the full path to the filename. But you have that line in the wrong place

do
{
    if( !fd.attrib & _A_SUBDIR )
    {
        ifstream in(findPath+fd.name);
        while( getline(in, line))
        {
           // blabla
        }
     }
} while( _findnext() );

)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you link with the *.lib file that was generated when you compiled the *.dll?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The only file you need in the test project folder is the *.dll. Actually, you can put it any of the folders listed in your PATH environment variable, such as c:\windows\system. As for the *.h file(s), just put the full path to where they are located in the include statement, e.g. #include "c:\mydir\test.h" Application programs do not need any of the other files you mentioned.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If DATA is defined as int, struct * can not be assigned the value of int without a typecast.

line 19: You can not free() individual elements of an array. The number of elements of an array are fixed when the array is declared and can not be changed. The best you can do is mark the element as unused so that is can be reused when another element needs to be added. That's most likely the purpose of liber.

That temp pointer is not needed. There is no reason to save the value of p[0] since p[0] is nothing more than an integer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Only limited way can class A use class B before class B is declared, class A can declare a pointer to an object of class B but that's about the extent of it.

class B; // pre-declare class

class A
{
public:
   B* b; // declare a pointer to class B


};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm Christian, but I don't believe in the literal interpretation of the Bible. Instead I believe that the Bible was written in terms that the people at the time of its writing could understand and their understanding of the world around them. Since they had no knowledge of the Americas the great flood of Noah's time was probably localized to his area of the world. To my knowledge (which is very limited) there is no evidence of such a great flood on this continent.

DavidKroukamp commented: your words precede your reputation :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Thatks -- I noticed that change and thought my eyes were decieving me :) Now, how about adding spell chedcking???

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I really didn't use much BBCode either, just code, color, quote, link and occasionally list tags. I think BBCode's Link and Quote tags were easier to use, and have not yet used mardown's List. I use Code tags the most, and markdown ~~~ is just as easy as BBCode [code][/code], actually a little easier since its less typing (I don't use the buttons at the top of the editor).

As for Heading and Sub-Heading -- never used it and probably never will. I would imagine Davy using them quite a bit.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I put the -9's there as sentinel values if that's right.

I don't think you need that. The instructions states the exact number of grades in each category, so all your program has to do is read that quantity of numbers. No need for a sentinel value.

setProg() -- you need to read each of the grades in individual variables so that the function can later make calculations. It can't do that when you read all the grades into the same variable. Same goes for the other set functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That one will be confusing to new posters because they won't realize what's going on. Just like anything else, for me its just a learning curve. Any other special characters that need to be escaped ?

I see from my previous post that the * doesn't need to be escaped when used inside code tags, which will not have a problem for anyone.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The way I once did it was to just search each character in line for a match in pattern. Warning: I didn't compile this so it might contain bugs, but it should give you the general idea

int includes(char *pattern, char *line) {
   int good = 0; // assume not ok

   int i = 0,j  = 0;
   while(pattern[i])
   {
       if( line[j] == pattern[i])
       {
           ++j;
       }
       else if( pattern[i] == DOT)
       {
          ++i;
          if( pattern[i] ) {
              while( line[j] && line[j] != pattern[i])
                 ++j;
          }
          else
             return 1; // line has pattern
          if( line[j] == '\0')
             return 1; // line has pattern
       }
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

testing: b*d

[edit]Success :)

Testing inside code ~~~ tags

b*d  // Not excaped
b\*d  // Escaped
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can not concantinate string2 to the end of string1 because (1) string1 is a string leteral so most likely its stored in read-only memory, and (2) there is not enough room in string1 to contain both strings. In main() try this:

char string1[80] = "my";

The above allows you to copy up to 80 charcters in the string1 buffer, which is located in writable memory because it is not a string literal.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The first sentence in the above post should have read "b * d" but do not use the spaces. For some readon the editor removed the * in the sentence.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I just found another bug in the editor. b * d (no spaces), the star is erased

See my post in this thread
http://www.daniweb.com/software-development/c/threads/420349/problem-searching-a-line-of-text

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

For the second part you could use a regexp (regular expression) library so that you would search for either bd or b?d, which * means any number of characters, and ? means only one character. So b?ne would find both bone and bane, whiew be whould find all the strings that start with the letter b and end with the letter e.

You could write your own simple reg expression function or use one of the existing libraries, such as this one:
http://www.gnu.org/software/libc/manual/html_node/Regular-Expressions.html

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sort both strings so thzt the characgters appear in the same order in both strings, then eliminate duplicate characters. After that, convert both strings to the same case, e.g. upper or lower, doesn't matter which. Finally call strcmp() to compare them.

Another method is to count the number of occurrences of each character in each string, then compare the two results. Create two int arrays, one for each string. The size of these two arrays is the same, regardless of the length of the two strings. For example

int count1[255] = {0};
int count2[255] = {0};
char s1[] = "FOOBAR";
char s2[] = "BFORAO";
int i;
for(i = 0; s1[i]; i++)
   count1[s1[i]]++;

for(i = 0; s2[i]; i++)
   count2[s2[i]]++;

// now compare the results
if( memcmp(count1,count2,sizeof(count1)) == 0)
{
   // the two are the same
}

There could be variations of the above, for example if you don't care how many times the same letter appears then just set the array element to 1, e.g. count1[s1[i]] = 1. To make case insensitive compare: count1[tolower(s1[i])] = 1;

strspn() will return NULL if you try to compare strings like FOOBAR and BFORAO.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

5) annoying, but I can live with it.

4) Agree completly with Walt. There must be an easier way top quote someone other than manually copy/paste Since you hate vBulletin's implementation, maybe a copy button that only copies/paste highlighted text.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't actually delete an element from the array. All you can do is mark it as an unused element. There are numerous ways to do that and it doesn't really matter which one you use as long as your program recognizes the element as being unused. For example, in the array you posted you could just set the word element of the array to an empty string, then when displaying all elements of the array if word is empty then just ignore it and move on to the next element.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use brackets or declare ofstream object before the switch statement.

switch(x)
      {  
        case '7':
        {
            ofstream filestream("Test.txt",ios::out|ios::app);
            //...
        }
        break;

        case '8':
        cout<<This is a test.";
        break;
      } 
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm happy to see the "Empty Inbox" and "Empty Outbox" buttons in our PMs :) Thanks for that nice feature Dani, the vBulleting method was always such a big hassle to do that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is what I have so far, where I'm I going wrong?

Don't know. What kind of problems are you having? If compiler error(s) then post the first two or three errors including the line numbers on which they appear.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Learning a programming language is not easy for most people, especially if you try to learn it by yourself. Forturnately, you have lots of help such as DaniWeb on the internet today. A good place to start is by reading one of the books suggested in this thread: http://www.daniweb.com/software-development/cpp/threads/70096/c-books

Take it very slow, don't try to read the book like you would a novel, and do all the exercises at the end of each chapter as well as test the code that's within the chapters until you understand what its trying to teach you. It can take a year or more to learn the language well enough to consider yourself a competent programmer.

Don't be afraid to ask us lots of questions. When you read something you don't understand, fire up you compiler, enter the code, compile it and run it. If you still don't understand then you can post a question here at DaniWeb and someone will attempt to help you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What libraries to use depends on your program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Hey guys, I am making a simple c++ compiler with Visual Studio 2010, but I am stuck on the converting it to assembly bit(with c++ coding).

The compiler will generate an assembly code listing for you. All you have to do is go to Projects --> Properties (at the bottom of the list) --> Configuration Properties --> c++ --> Output Files then change one of the options to whatever kind of listing you want.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What is wrong with using win32 api functions FindFirstFile() and FindNextFile() ? Can't DDK programs access win32 api?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A good place to begin is here. That will only scratch the surface of MS-Windows programming. A better way to learn it is to buy a book from amazon.com.

I also love www.codeproject.com, probably the largest repository of free MS-Windows code on the internet.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your requirements are pretty steep (challenging) for someone brand-new to C++

My guess is that course is NOT intended for beginners. Most likely an advanced programming course for which the OP does not have the prerequisites. If it is a beginner's course then fire the instructor and drop the course.