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

After the cin statement if a < b then just swap them so that you don't have to code for that condition.

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

>> could i have just passed &dims?
Yes. Don't dynamically allocate things unless you absolutely have to.

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

CRect is only 4 integers, so why bother allocating it at all. Just declare it without allocation and save yourself the bother of finding memory leeks.

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

all you need is the HWND -- see RedrawWindow()

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

Its defining a pointer to a specific address. Works ok (probably) in MS-DOS version 6.X and earlier where that type of syntax was sometimes used, but it will fail in any modern 32-bit operating system such as MS-Windows and *nix. So if you are using a modern compiler then those defines because they won't compile.

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

see SetTimer(). With SetTimer() you can have windows call a function of your choicel at set time intervals.

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

>>Because of this thread is not closed yet
We don't close threads unless we have to normally when someone starts behaving badly or flaming starts.

Please post the whole program so we can run it and compare execution times with different computers.

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

search www.microsoft.com for CListBox. You can find everything you need there, and for all the windows classes. You should use that for all your MFC questions, if you can't find it there then post question here. There is a lot of things though that MSDN doesn't tell you.

You should also be able to just press <F1> while in the compiler's IDE and it will take you right to the search box. I'm being a little bit evasive because you need to learn how to look it up yourself.

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

yes, and yes. If you want to know how to change the listbox contents, just read the methods that are available and you will find it (I don't recall off the top of my head.)

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

>>Can I do easily a dll for windows without using Microsoft Visual C++ compiler ?
yes, you can use most any compiler that targets MS-Windows version 2000 or later.

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

I always have problems using fstream too. So I try to avoid it and use ifstream or ofstream instead.

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

You can add controls, but it might be easier to use CFormView which is derived from CView but acts like CDialog.

To add a button to your CView, just create an instance of CButton in the CView's class, then when initializing CView class call the button's Create() method. Of course before calling Create() you will have to create a CRect (or just RECT) which you pass to Create(). I don't have an example to show you but its not all that difficult to do. It may take a few tries to get the CRect coordinates just right because you can't do it visually like you do with CDialog or CFormView.

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

I've always seen the modes used as ios::in | ios::out | ios::app

So have I, but see the example here

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

On the openfile line, are you telling the compiler that it should check the following:

fstream::in (or) fstream::out (or) fstream::app???

if so you are short 1 | for each instance (an OR command is ||)..

if not, then completely disregard all the above and kind of explain what you're trying to accomplish on that line.

Wrong. The | operator is NOT a boolean operator but instead is a bitwise OR which adds the values together. The op's use of the | operator is correct.

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

>>i'm a first year college student and just starting with turbo c.
OMG go to a different college immediately because you won't learn anything where you are at. That compiler has been obsolete for at least 15 years that I know of.

>>unable to open include file conio.h
Check the compiler's include directory to see if that file really exists or not.

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

you are attempting to pass just one element of the array, not the whole array. When passing the array you have to leave out the subscripts comparison (number);

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

line 25: what's the value of i and j? A: random

line 33: you are using the assignment operator = instead of the boolean operator ==.

which of the lines you posted is line 52 in your real program (error #1)

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

sleep takes parameter in seconds -- I think there is a usleep that is in milliseconds.

If you stick to standard c++ code there should not be a problem. But if you use a lot of win32 api graphics functions then you are in deep shit. Most of that is comletely different in the *nix world. My advice is to use a portable library, such as wxWidgets or QT.

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

thanks.

I will read the textbook.

Oh what a great idea! :icon_idea: Someone going to actually read his textbook :)

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

Hey sampson: don't you guys ever run an antivirus program on your computer? I have one running whenever I boot my computer and have never in the past 10 years had a problem. The antivirus program won't allow a download if the file contains a virus. There is no excuse for catching a computer virus today (except in rare cases where its a new virus).

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

Just a simple text file will do -- I doubt your instructor wants something as complex as an SQL database.. Use ofstream to output the data and ifstream to read it back. Both are declared in the header file <fstream>.

If you don't yet know how to use those two c++ classes then I'd suggest you read your textbook because it most certainly covers that topic. Also look in the Code Snippets board (link at the top of every DaniWeb page).

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

>>time_t now = time(res[1]);
That's wrong -- the parameter to time is a pointer to a time_t object. I don't know what you are passing but it isn't time_t*

If you are attempting to convert the date/time in the result set to time_t, that is the wrong way to do it. win32 api FileTimeToSystemTime() will convert that FILETIME object to a SYSTEMTIME structure, which is similar to struct tm, but has milliseconds, and you can easily access the month, day, year, hour, minutes, seconds, and milliseconds.

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

delete the semicolon on line 4. defines don't end with a semicolon. It would be better to use a const int instead of that #define const int ingresos_totales = 5;

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

First figure out the algorithm on paper, then code it.

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

A little easier one to use is ShowWindow() Get the first parameter by calling GetConsoleWindow()

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

>>The outcome is not write.
write means to scribble something on a piece of paper or in a file. What you want is the word right which means correct.

1) All arrays are numbered from 0 to the number of elements in the array. In your example the array has elements numbered 0, 1, 2, 3, 4, and 5. Count them on your fingures -- that is 6 elements.

2) why does i get incrementd from 1 to 32 when the array only has 6 elements? After the program will just scribble all over memory and what happens can be any one's guess (called undefined behavior).

Take another look at those two loops, count them on paper or in your head so that you can see in your mind what is wrong with them.

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

Oh I see now what you meant. I thought you meant sizeof(char) in c++ is different than in C.

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

Watch the video here

To compile a C program just create an empty console application then add the *.c file(s) to it.

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

In essence, char type in C (but not in C++) is a very short int, that's all.

I think you will find char data type is the same in both c and c++.

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

This question has been asked and answered millions of times. Click here.

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

Here is how to test command-line arguments. Run this program from a cmd.exe command prompt to see how to get the arguments into the program

#include <iostream>
using std::cout;

int main(int argc, char* argv[])
{
   for(int i = 0; i < argc; i++)
       cout << argv[i] << "\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I usually issue warning and/or infraction for users with more than 5 posts who don't use code tags. And it normally has taken no more than one two-point infraction to get someone to mend his/her ways because I remind him that he could get banned for not using code tags, which would be a real shame.

And I often give a first-time poster good rep for taking the time to actually Read the Rules and use code tags correctly.

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

I am running Vista Home, created a CLI/Windows Forms project and still only get Win32 solution platform.

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

>>Why is it that the samples on the MSDN Learning center cannot be compiled
Link please so we can check it out

>>With Itanium as the active solution platform by default
I don't have that option on my computer. Only win32. But I suppose you have to be running 64-bit version of the os in order to get it.

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

you can use std::transform() to convert the strings to either upper or lower class then use the comparisons

std::string s1 = "Hello";
std::string s2 = "HELLO";

std::transform( s1,begin(),s1.end(),s1.begin(),touper);
std::transform( s2,begin(),s2.end(),s2.begin(),touper);
if(s1 == s2)
{
   // do something
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

For stats.getline(counter,200); It works without the for loop too. If I understand this correctly, the while (!stats.eof()) will help loop and get the data from the text file.
So why do I need another while loop?

Appreciate the help :)

You don't need another while loop -- just correct the while loop you already have. eof() doesn't work the way you think it does and will cause the loop to execute one too many times. Replact that with what I posted and the loop will work correctly.

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

I think you misunderstood what strlen() does -- it returns the number of characters in the buffer up to, but not including, the first byte that contains 0. That is normally smaller than the number of characters that the buffer can hold.

Example: char buffer[255] = "Hello"; In the above, strlen() will return 5.

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

first problem: the while statement is incorrect. Here is how to do it. while( stats.getline(counter,200) ) Why do you think strlen() doesn't work? Its been working correctly for millions of programmers all over the globe for over 25 years, so I doubt it has a bug.

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

>>I have used char *per because 'write' function only accepts pointer to character.
False. You can put anything you want to there -- just typecast it to char*


But you still failed to correct the problem. per is still an unallocated pointer which will crash your program.

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

1) static is a scope operator that limits the scope of the function to the *.c file in which it is declared. If you have two *.c files, each file could contain a function with the same name as long as the function is declared static. IMO its poor programming to have two functions like that, but it is possible.

2) compile it and find out what happens.

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

your program is close, but close isn't good enough. The call to Sort() is in the wrong place -- only call it once after all the data file has been read. Also the use of some variables is inconsistent in the loop that reads the data file. I also made a slight change to the sort algorithm.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>

using namespace std;

const int rows = 12;
const int cols = 8;

void HEADING();
void Sort (string [],string [],int [],float [][8]);
void AVERAGEDISPLAY(float average, float average2);
void displayarray(string [],string [],int [],float[][8], int);




int main()
{	
	ifstream inData;
	int names=0;
	string lastname[rows], firstname[rows];
    int studentID[rows] = {0};
	int i=0,j;						//for rows and cols
	float sum=0,total, total2=0;    //subject and score totals
    float studentgrades[rows][cols] = {0};
	float average=0,average2=0;		//average subject and score averages
	

	inData.open("..\\TextFile1.txt");
	
	HEADING();//display heading

	while (inData>>lastname[names]>>firstname[names]>>studentID[names])
	{
		cout<<lastname[names]<<" "<<firstname[names]<<" "<<studentID[names]<<" ";
		
            
			for (j=0; j<cols; j++)//loop for studentgrades
            { 
	         inData >> studentgrades[names][j];
	         cout<<fixed<<setprecision(1)<<setw(5)<<studentgrades[names][j]<<" ";
			 sum=sum+studentgrades[names][j];//adds subject grade for individual student
			
            }
			total2=sum/cols;//averages individual student grade
			cout<<setw(5)<<total2;
			average+=total2;//adds for average grade
			sum=0;
			names++;
			cout<<endl;		
	}
    Sort(lastname,firstname,studentID,studentgrades);	
		cout<<endl;
		cout<<"SUBJECT AVERAGES ARE:";
		
		for (j=0; j<cols; j++)//loop for subject averages
		{	total=0;
            for (i=0; i<rows; i++)
            { 
	         inData >> studentgrades[i][j];
			 total+=studentgrades[i][j];//adds subjects only
            }
			cout<<fixed<<setprecision(1)<<setw(5)<<total/rows<<" ";
			average2+=total/rows;//adds subject averages
		}


	AVERAGEDISPLAY(average, average2);//displays student and subject grade averages
	displayarray(lastname, firstname,studentID,studentgrades, rows);
	inData.close();

return 0;
}
//****************************************************************************************
//****************************************************************************************
void HEADING ()
{
cout<<"-Student Name   ID    SUB1  SUB2  SUB3  SUB4  SUB5  SUB6  SUB7  SUB8 AVERAGE-"<<endl;
	cout<<"----------------------------------------------------------------------------";
	cout<<endl<<endl;
}
void Sort(string lastname[],string firstname …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

the sort algorithm is wrong. You have to swap all elements of grades array at the same time that the string in word is swapped. You can delete aName2 array.

if (word[k] < aName)
{
    // first swap the string in the word array
    aName = word[k];
    word[k] = word[i];
    word[i] = aName;
    // now swap the elements of the float array
    for(int j = 0; j < 8; j++)
    {
         float temp = grades[k][j];
         grades[k][j] = grades[i][j];
         grades[i][j] = temp;
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

typecast it ofs.write((char*)array,512);

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

>>cin>>*per;
As mention before, per is a pointer that just points to some random memory location. and *per only references the first byte, not the entire string. Unless the purpose of this assignment is to learn character arrays and pointers, then you would be better off using std::string.

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

HA! I just realized I spelled please wrong in the title! That's embarrassing. Lol!!

Ok -- now I'm going to have to ban you for misspelling that word :) Unless you have a Ph.D. in English, don't worry about the small stuff.

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

He-he that will be because Java phones don't have such things ;)

Web development is still tricky for all mobile platforms as not many websites have portal for mobile access like large companies such as BBC, London Transport, Google, Yahoo etc.

Then the OP should have been more specific about the type of mobile hardware he is targeting. I didn't realize cell phones software was written in java. But then I know next to nothing about Java anyway.

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

I've developed over 40 applications for Mobile 5.0 and Pocket PC using Visual Studio C++. I was able to accomplish a lot of things that most likely are not possible to do with Java, such as forbidding users to access the Today screen, disabling the Start button and the big X in the upper right corner of the screen. None of those programs involved the Web, so if what you're trying to do is web based than java is probably better.

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

this might be one way to resolve the different parameters problem. Pass the parameters you want as the seccond parameter and use stdargs.h to retrieve them. If you don't want to do that, then you might get away with using templates, but someone else will have to answer that question.

#include <iostream>
#include <vector>
#include <string>
#include <stdarg.h>
using namespace std;

void A(char* fmt, ...)
{

}

void B(char* fmt, ...)
{

}

int main()
{
    std::vector<void (*)(char* fmt, ...)> fns;
    fns.push_back(A);
    fns.push_back(B);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The constructors are not PUBLIC.

What compiler are you using? Did it produce any warnings or errors that you failed to correct? You should treat all warnings as if they are errors because most of the time warnings are indeed errors.

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

Ehh ?? Those aren't errors.

Oops! you are right -- I didn't read it close enough.

William Hemsworth commented: Hehe, you make me laugh :) +3