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

Welcome to DaniWeb. Ask your question(s) in the appropriate Software Development forum and I'm sure someone will be glad to answer them. Won't be me though because I know nothing (well almost nothing) about VB.

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

We know the requirements - you posted them in your original post.

Exactly what is it that you don't understand? If your compiler is producing errors, what are they? BTW the function prototype for fnTelephone_Num() is no longer consistent with the actual function. The parameters have to be identical.

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

Not everyone in US owns guns -- I don't. It really depends on where you live whether you would need a gun or not. I live in a nice little rule town where there is no crime -- the town cop doesn't have a whole lot to do. But drive 30 miles away from here and there is St Louis Missouri, a city of over a million people and very high crime rate. Drive-by shootings and murders is just a daily normal occurence in that town due mostly to drug wars and gangs. This is not to say that St Louis is all a war zone -- some parts are pretty good.

In a perfect world you are right that we would not need guns except for hunting food. But we don't live in a perfect world.

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

LMAO :)

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

Getting "technical" is an absolute requirement in software development :)

jonsca commented: Props on your new avatar +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You posted the assignment, now tell us what question you have ???

>>int fnGenerateTelNumber(char cTelephone_Num)
That only declares a single character, not an array of characters. You have to
declare it like this: int fnGenerateTelNumber(char cTelephone_Num[]) or any of its other variants:
int fnGenerateTelNumber(char* cTelephone_Num)
int fnGenerateTelNumber(char cTelephone_Num[7])


When you declare the array in main() make sure you include space to hold the null-terminating character. If you want a 7-digit telephone number then the charcter array must be at least 8 bytes.

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

LOL, am I the only one that uses www.msdn.com? That is like the end all be all of resources.

Only if you program for MS-Windows.

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

You can thank the Chinese for the arms we have today because they invented gun powder in about 850 A.D. Without that we would still be throwing rocks at each other.

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

You've been watching sci-fi too much :)

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

1) functions have to be declared before they can be called. You need to add function prototypes before the main() function. For example: void readTemp(int kelvinNumber); now do the same thing with all the other functions.

2) There is no reason for main() to delare the two variables on lines 10 and 11 since main() does nothing with them. Just remove the parameter from the two functions and declare the variables inside the two functions that are called from main().

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

You can use any modern c or c++ compiler, such as Code::Blocks or VC++ 2010 Express (both are free). Do NOT use Turbo C or Tubro C++ because its too old and can not access any of the win32 api functions.

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

Yes, of course it is possible. The entire win32 api (excluding .NET), including all graphics functions, were written in C language.

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

You don't. graphics on *nix is completly different than it is on MS-DOS/MS-Windows. Here is a source for linux graphics questions. You will have to be a member of their forum if you want to view that link.

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

graphics.h is not supported by any *nix compiler -- it was developed for Turbo C on MS-DOS 6.X and older operating system. So you might as well forget about trying to use graphics.h on *nix or with g++ compiler.

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

Turbo-c console program? No. You have to use the font size that is built into your computer. To change font sizes requires a graphics program, and then you have to either create the fonts yourself of get the fonts from someone else.

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

Here is an interesting thread about the topic of individual rights to own and keep weapons in the USA. The original intent was to give evey American citizen the right to have weapons so that he can defent himself, his family, his home, and his country against foreign invaders (like England) or other people who intend to do harm. And that today is still the main reason. Americans are paranoid about any one or any nation enslaving them.

December 15, 1791

George Washington <former US President>: "A free people ought not only to be armed and disciplined but they should have sufficient arms and ammunition to maintain a status of independence from any who might attempt to abuse them, which would include their own government."

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

>>Does it matter which one?
No. You can use either, but integers are most common. If you use char then the compiler will have to take the time to promote it to an integer before its used as the index into the array. So you can speed up a program by a few nanoseconds by using ints instead of char.

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

>>Does this mean that int and char are not objects?
Yes -- they are not objects. They are data types. A string is not an object either. It is a c++ class that is defined in <string> header file. Objects are an intstance of a data type or c++ class

int x; // x is an object
std::string name; // name is the object
char address[255]; // address is an object
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

For MS-Windows GUI then www.codeproject.com is a wealth of free code, libraries, DLLs and tutorials. Probably the largest repositories of code on the net.

Lusiphur commented: Thanks for the reference link :) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You need to read a tutorial about win32 api programming. Here is a very popular one. Do all the exercises in that tutorial and then you will understand the code you posted.

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

google is your best friend.

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

Anything you want. GUI? games? networks?

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

6 hours? OMG next time use google! Here is how to do it.

wchar_t wname[255];
std::string name = "John";
size_t convertedChars = 0;
mbstowcs_s(&convertedChars, wname, sizeof(wname)/sizeof(wname[0]), name.c_str(), _TRUNCATE);

IGUIEditBox* player = env->addEditBox(wname, rect<s32>(170, 80, 320, 100));
cwarn23 commented: Life saver +5
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> input[0] = toupper(input[0]);

And what will happen if the first character is white space?

#include <iostream>
#include <string>

int main()
{
    std::string line;
    while( std::getline(std::cin, line) )
    {
        std::string::iterator it = line.begin();
        for(; it != line.end() && isspace(*it); it++)
            ;
        *it = toupper(*it);
       std::cout << "\"" << line << "\"" << '\n';

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

>>i have c compiler so can i use it or i need c++ compiler and where can i get it

Depends on the C compiler you are using. Most modern compilers will compile both C and C++, depending on the file exten. *.c is normally compiled as C code while *.cpp or *.cc is compiled as c++. But you will have to test your compiler to find out how it behaves.

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

"a" is a pointer to the letter 'a', it is not c++ class std::string. You can only use the + operator on std::string

std::string a = "a";
std::string b = "b";
std::string c = "c";
std::string text = a+b+c;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I just gave you more rep to see if that would change it, but that didn't help either.

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

Yes it should. I recall Microsoft has a similar problem at one time with vc++ 6.0 compiler -- the problem was in a header file which they eventually fixed.

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

Repost your question here -- it is specifically for mac

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

make sure you include stdio.h and that you add main() function. The code in your link is not a complete program.

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

Line 4: remove that semicolon at the end of the line. That is what is causing the error message.

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

Oh, you don't mean "produce" -- the compiler does not produce any code, native or otherwise, except for the templates when you create a project. What you are asking is how to mix managed and unmanaged code. Here is an article on MSDN which should apply to all .NET compilers.

Here is another article that shows how to mix them in c++/clr program. How to use that in Windows Forms? I have not tried it but I assume the technique might be very similar, if not identical.
[edit]Note: I tried that technique and vc++ 2010 express didn't like it. The article was written in 2003 and probably very obsolete.[/edit]

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

what do you mean by "native code"?

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

Here is a guy whom I suspect wishes he had used a holster.

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

Absolutely and most definately not. The first thing all dictatorships do is take away the ability of its citizens to defend themselves. And it has been demonstrated over and over again, time after time, that crime INCREASES when guns are restricted or banned.

Just one of many many examples

http://justfacts.com/guncontrol.asp

  • In 1982, a survey of imprisoned criminals found that 34% of them had been "scared off, shot at, wounded or captured by an armed victim." (16c)
  • Washington D.C. enacted a virtual ban on handguns in 1976. Between 1976 and 1991, Washington D.C.'s homicide rate rose 200%, while the U.S. rate rose 12%. (1)

>>It always makes me laugh when I hear, "guns don't kill people, people kill people." I don't see many people killing each other with a spork.
Thats because you are an idot and have no clue. Many people have been killed with knives, pitchforks, and all sorts of objects.

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

>>close(mfdprot);
You probably meant fclose(mfdprot)

Sounds like your operating system is buffering up the data. Try adding fflush() before fclose().

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

The compiler will generate a pointer to the first character of a character array if all you pass is the array name, The & symbol is optional. If you want a pointer somewhere else in the array then you have to use the & operator and tell it which byte you want the pointer to start.
char buf[255];
scanf(buf, ...);

The above line is the same as this one:
scanf(&buf[0] ...)

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

post the contents of the input file. Does it contain numeric digits only or can it contain non-numeric characters? How to parse the file will depend on what it contains.

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

If the 8 bit variable is passed by value then there should not be a problem because the compiler doesn't pass 8 bit values anyway, the smallest that can be put on the stack is 16 bit variables (with a 32-bit compiler on an Intel beased computer). Casting can lead to huge problems if the variable is passed by reference (or pointer) because then the receiving function will be expecting a pointer to a 16 bit variable.

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

Once you know one language its not all that difficult to learn another. IMO VB.NET is easier to learn than c++.

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

If you don't want to do it in Excel or as a CVS file as previously mentioned, then I'd go with VB.NET because I think it has built-in support for Excel files. But then I could be wrong because I don't know a whole lot about vb.NET.

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

you mean this? I don't know why your program is trying to read 37 files, so I'll just kind of ignore that minor detail and hopefull you can figure out how to do it from the code I am posting below.

#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

void display(std::vector< std::vector<int> >& arry)
{
    for(size_t i = 0; i < arry.size(); i++)
    {
        std::vector<int>& cols = arry[i];
        for(size_t j = 0; j < cols.size(); j++)
            std::cout << cols[j] << ' ';
        std::cout << '\n';
    }

}

int main()
{
    std::vector< std::vector<int> > arry;
    for(int who = 1; who < 37; who++)
    {
       std::stringstream str;
       str << "b" << who << ".txt";
       std::ifstream in(str.str());
       if( in.is_open() )
       {
           int nclus, m, n;
           in >> nclus >> m >> n;
           std::vector<int> cols(n, 0);
           for(int i = 0; i < m; i++)
           {
               for(int j = 0; j < n; j++)
               {
                   in >> cols[j];
               }
               arry.push_back(cols);
           }
           in.close();
           in.clear();
       }
    }
    display(arry);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

We don't do homework for you. You do the homework, we just help. So post what YOU think are the answers.

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

Note that main() always returns int, never ever void.

#include <fstream>
#include <iostream>
#include <string>
#include <sstream>

int main()
{
    for(int who = 1; who < 37; who++)
    {
       std::stringstream str;
       str << "b" << who << ".txt";
       ifstream in(str.str());
       // etc. etc.
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>It runs but gives me a run time error similar to one I had before
It will depend on where you declared those strings. If you declared them in main() like the code I posted then there should not be a problem. On the otherhand if you declared them in some other function and tried to use them after that function returned then all those strings will have been destroyed and invalidated all those pointers.

As firstPerson mentioned the best practice would be to use a vector of strings in that class and not a pointer so that the class owns the memory of all those strings. That way you won't have to worry about the strings going out of scope.

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

There were a lot of compiler changes between the two versions that you are using -- 6.0 and 2008. One of the changes is that 2008 uses UNICODE strings by default. You can begin to analyze your problem by turning off UNICODE. Go to menu Project --> Properties (at the bottom of the list), expand Configuration Properties tab, select General. Then on the right side of the screen, third item from the bottom change "Character Set" to "Not Set".

There are several improvements I could suggest to your program, but I suppose you just want it to work for now, so I won't mention them.

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

I'm confused. You want a std::list of matrices -- each node in the std::list contains a different matrix? Something on this order?

#include <list>

class matrix
{
public:
   matrix(int rows, int cols) 
   {
      data = new int*[rows];
      for(int i = 0; i < rows; i++)
         data[i] = new int[cols];
   }
private:
   int ** data;
};

int main()
{
    std::list<matrix> matrices;
}

>>There is no my matris define. Is there any way to get a value on a matrix in a list exactly like "matx[3][4]"

Using the above code -- the answer is no because the variable matrices in main() is not a 2 dimensional array or list.

If on the otherhand you don't really want that std::list then you can write an overloaded [] operator to do what you want with must the c++ class I posted.

int main()
{
   matrix matrices;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The result is undefined behavior because of the ++ operator. max() evaluates both variables a and b twice, so the ++ operator gets executed twice. Exactly what the final result will be is compiler implementation dependent. Your compiler may produce one value while another compiler may produce something else.

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

>>sPtr=&s;
Wrong. should be sPtr = s; . But you really don't need that line, or the previous line, at all since both variables are being initialized on line 1 of the code snippet you posted.

This worked for me

#include <string>
#include <iostream>
using namespace std;

class someclass{ 
public:
someclass::someclass(int arraysize, string s[]): numElements(arraysize), sPtr(s)
{
}

friend ostream& operator<<(ostream& out, someclass& c);
private:
string *sPtr;
int numElements;
};

ostream& operator<<(ostream& out, someclass& c)
{
    for(int i = 0; i < c.numElements; i++)
        cout << c.sPtr[i] << '\n';
    return out;
}

int main()
{
string s[4]={"a", "ab", "abc", "abcd"};
someclass c(4,s);
cout << c << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

"new double" is not a variable. "new" is a c++ operator that allocates memory from the heap, and "double" is the type of memory that new will allocate.