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

lines 113-117 are wrong, you have them backwards. See the lines I posted. I think you also have them in the wrong event handler. Should be

private: System::Void BuyRadio_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
			    if ( IsClicked )
                     IsClicked = false;
               
				else
                     IsClicked = true;
             }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> I have trid to press the button without pressing the radiobutton also.
what does that mean?

At this point I think you need to post the code for the form that contains the radio button.

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

The way I did it was like this: (see line 10 and 28)

public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
                           this->IsClicked = false;
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
    private: System::Windows::Forms::Button^  BuyRadio;
    protected: 

	private:
        bool IsClicked;
<snip>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you trying to do this from C++? or from Delphi? If Delphi you are on the wrong board and I'll move it to the correct board.

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

Forget about the two I mentioned above. You need to handle the Click event. You need to have your own bool variable to indicate whether the button has been clicked or not, then implement an onClick event handler to set or reset that variable. Something like below. IN the below, IsClicked is a class bool variable. Now wherever you want just look at the IsClicked varialbe.

private: System::Void BuyRadio_Click(System::Object^  sender, System::EventArgs^  e) {
                 if( IsClicked )
                     IsClicked = false;
                 else
                     IsClicked = true;
             }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First, don't rely on the compiler's IDE to give you all the methods -- look them up in MSDN so that you can read their description. RadioButton class is here. Look at the members and you will find IsChecked method.

if( BuyRadio->IsChecked() == true)
{
   SetNumber = 1;

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

I thought it was "legal" to mix parameter lists.

Yes, you can mix and match as you wish.

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

Of course its legal -- you just forgot the & symbol after int

int afunction(ifstream& in, int& anumber)
{
/* Function Body */
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you using ancient Tubto C or Tubro C++ compiler? Those two compilers are sooooo old that they aren't of any value to learn c++. Toss them out and download one of the free modern compilers. Dev-C++ and Microsoft VC++ 2008 are both good ones. There are others too, such as Eclipse, mentioned by codeaa above.

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

BuyRadio is a c++ class object, not a POD (Plain Old Data) type so you can't treat it like that. You must give the class a method that will return the button's state.

if( BuyRadio.GetState() == true)
{
   SetNumber = 1;

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

line 8: void main()
main NEVER EVER returns void. It always returns an integer.

line 15: unrecognized escape character "\(" as well as "\)" and "\:". You can't escape those characters, just delete the "\" character.

Those same errors appear several more times in your code. Correct them and the rest of your program will compile ok.

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

piece of cheeze

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

MFC is Microsoft Foundation Class and the oldest of the three. It is mostly wrapper functions for win32 api functions, and makes windows programming pretty easy. Requires a very good foundation and knowledge of c++.

ATL (Active Template Library) is somewhat similar to MFC but revolves around C++ templates and doesn't contain all the bulk that comes along with MFC.

CLR is the newest of the three (I don't recall what that acronym stands for) and has nothing at all to do with writing MS-Windows programs but instead is a way of writing what Microsoft terms Managed Programs. I don't really know much more than that about it because I have not used it.

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

line 51: That is an ILLEGAL way to declare an array. You must specify its size.


lines 57 and 58: What happens if OnRelease() returns -1, as it will in line 46? Answer: crash your program.

Where (line number please) do you want to use atol() ? If you are getting the letters from the keyboard one character at a time than atol() may not be necessary.

int key = 0;
char k;
// convert letters to format an integer.
while( (k = getKeybord()) > 0)
{
    key = (key * 10) + k - '0';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

put it in a library or dll and distribute the .h file with the lib or dll.

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

The problem seems to be nested includes. Each header files includes the other header file, so neither header is completly processed before the class is used in the other header. To avoid that problem predeclare the class. See the example below

Second: stdafx.h is not to be included in header files. This file must be included at the top of *.cpp files and must appears as the first include file. If you don't do this and you compile with precompiled headers then your program will not compile.

#ifndef __fibonaci__
#define __fibonaci__

#include "stdafx.h" // <<< this is not necessary in header files 

#include "Fibonaci_Iterator.h"

class Fibonaci_Iterator; // <<<<<<<<<<<<<<<<<< here

using namespace std;

class Fibonaci
// rest of header file here

Even if you make the above change you are going to have fatal problems because pre-declared classes can only appear as a pointer since the class has not been fully declared to the compiler. Looking over your code I think the easiest way to solve your problem is to remove line 4 from Fibonaci_Iterator.h

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

my code on the line of error

const char * "c:\\My Programs\\myfile.txt" = argv[1];

That line is malformed. Should be either

const char * pFileToDelete = "c:\\My Programs\\myfile.txt";

or
const char * pFileToDelete = argv[1];

Use argv[1] line if you want to type tye filename on the command line when you execute your program. Otherwise if you just want to hard-code the filename into your program use the first version.

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

How would I declare the delete file function,

just #include <windows.h> If you don't have that installed on your computer then you can't use that function. Use the standard C function remove() instead.

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

It looks like it should work. Use your compiler's debugger and set a break point on that return statement then when the program gets to that point you can inspect the value of all the variables. If you don't know how to do that then just put some cout statements to display the variable values.

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

You have to write DLL in C. Here's some information about that.

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

line 16: I don't know what compiler you are using but mine won't compile that line because arrays expects a const value. Maybe there is something new in C99 ? Most compilers will not like that line.

>>I get an infinite loop if my random number is 0
Yes because you can't have arrays of size 0 int array[0] is not a valid array. Maybe add 1 to the rand % MAX value, then change MAX to 19 instead of 20 to avoid that problem.

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

You need to start reading the descriptions for the System::String methods in msdn so that you can learn how to look up the method(s) you need to solve your problems. What you need is a method that will locate (or find) the last '\\' in the string then another method that will take the substring of all the rest of the characters.

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

tabs are considered white space so they are treated just like spaces. But you (jamthwee) are correct about newlines, so my previous suggestion will not work. But there is hope. Use getline() to read the entire line then stringstream to split it up into individual words similar to what I posted before. I was about to post the solution, but then I would be doing the OPs homework for him wouldn't I ?

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

If you want to put all those 100 numbers on one line you will have to change the font size to something very very tiny -- so tiny you probably won't be able to read the numbers.

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

You do NOT declare aTable -- aTable is a mistake. You need to correct the spelling.

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

Look at that first error message, then look at your program. Do you see aTable defined anywhere ? Answer: NO you will not. Well what do you think you need to do about it? Hint: Check spelling and capitalization.

You also need to include <iomanip> to get the setw function declared.

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

why don't you do this the easy way by using the ifstream >> operator to remove all white space between words with output the word just read with one space

string word;
while( infile >> word)
   outfile << word << " ";
SpS commented: plain and simple +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I already posted examples of how to do it. The i loop increments the rows. The j loop you coded increments the columns. But you don't need the j loop because cin will do that for you.

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

char arr[20][50]; You declared it as a 2d array. cin will do the difficult part of filling in the 2nd dimension for you like you were attempting to do.

>>how is that a two D array itz just arr a 1D array
arr is still a 2d array. If you aren't still convinced then try out the code I posted and see for yourself how it works.

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

But those menu lists are strings. "Burger" is a string and "Patty" is another string. Treat them as you would any other string.

>>Anf its specified in the assing ment to input and store in a 2D array.
The suggestions I posted meet that requirement.

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

Why even use a J loop? If you want to enter strings then just do this:

for(i=0; i<no; i++)
    cin>>arr[i];

You won't get spaces in the above, so if you need the spaces too then use getline()

for(i=0; i<no; i++)
    cin.getline(arr[i], sizeof(arr[i]));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are running Vista then read this thread

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

search for "sort algorithms" and you will get a lot of help. There are a lot of algorithms, which one were you instructed to use ? The Bubble Sort is probably the easiest to code.

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

I read the manual. Go to www.microsoft.com and enter the function name in the search box. Follow the links and you eventually find an example program.

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

Here's the correction

int main()
{
   HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); 
COORD NEW=GetLargestConsoleWindowSize(hStdout);
printf("%d\n",NEW.X);
printf("%d\n",NEW.Y);

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

well i have requirements to follow but it doesn't say i can't use an array but I'm sure it has to be something we covered in class and i don't think std::string word is something we covered.

If you have not covered std::string yet then replace it with a simple char array

char word[40];
while( inFile >> word )
{
   // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well in that case you need to use the answer in the open statement instead of hardcoding the filename. line 19 should be this: inFile.open ( cloze );

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

If you are going to hardcode the filename then there is no point in lines 14, 15 and 16, so you might as well delete them.

>>also is that what is called using an array??
No. Nothing I posted uses an array. I see no reason to use an array in this program, unless there is some requirements that you didn't post.

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

ok, you're right it is cloze -- my bad. I should have looked it up before critizing you for that.

Back to your problem: lines 23 thru 35 are all wrong. You want to read the file one word at a time, not one character at a time. The >> operator will do that very easily

std::string word;
while(inFile >> word)
{
    cout << word << " ";
}

now after the above finished just rewring the file using seekp() then clear all errors and read it the second time with the replacements you have to do.

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

what do you mean by "cloze <sinc> test" ? BTW: its spelled close not cloze. Do you mean to close the file and reopen it for the second reading?

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

>>It's supposed to be a cloze test...
Doesn't that mean you're supposed to write the program without help from anyone? If yes, then isn't asking us for help the same as cheating by looking in your textbook?

line 19: why is the filename hardcoded instead of using the name you have to type at line 15?

delete lines 20 and 21 because that's the default behavior when a file is opened.

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

Here is a version that doesn't crash when ran. I completly replaced your read_word() function to use fscanf() -- its a lot easier when just reading space-deliminated words from a file.

The program does not meet all the requirements, but at least it doesn't crash.

#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma warning(disable: 4996)

#define ch_limit 500

struct node {
	char word[ch_limit];
	int count;
	struct node *next;
};

typedef struct node *list;

int count_lines(FILE *fp)
{
return 0;
}

list populate(char *word,list first)
{
        list temp = NULL, node = NULL;
        int value=0;
        temp=(list)malloc(sizeof(struct node));
        memset(temp,0,sizeof(struct node));
        strcpy(temp->word,word);
        temp->count=0;
        temp->next=NULL;

        
        if(first==NULL){
                return temp;
        }
        node = first;
        while(node->next!=NULL){
                if(strcmp(node->word,word)==0){
                        node->count++;
                        free(temp);
                        return first;
                }else{
                        //printf("I am inside\n");
                        node = node->next;
                }
        }
        if(strcmp(node->word,word)==0){
                node->count++;
                free(temp);
                return(first);
        }
        node->next=temp;
        return(first);
}
list read_word(FILE *input_file)
{
    char word[ch_limit] = {0};
	list first=NULL;
    while( fscanf(input_file, "%s", word) > 0 )
    {
			first=populate(word,first);	
    }
    return first;
}
/*
list read_word(FILE *input_file)
{
	char word[ch_limit];
	int ch;
	int i,count=0;
	list first=NULL;
	
	while((ch=fgetc(input_file)) !=EOF){
		
		for(i=0;(ch!=' ') || (ch!='\n');i++){
			word[i]=ch;
			ch=fgetc(input_file);
			if (ch == EOF)
				break;
		}
			word[i]='\0';
			first=populate(word,first);	
			
	}
	return(first);
}
*/

void display(list first,int line_nos)
{
	list unique,common;
	common=unique=first;
	if(unique==NULL){
		printf("The list of unique words is empty\n");
		return;
	}
	printf("Unique List: ");
	while(unique){
		puts(unique->word);
		printf(" ");
		unique=unique->next;
	}
	printf("\n");

	if(common==NULL){
		printf("The list of common words is empty\n");
		return;
	}

	printf("Common List: ");
	while(common){
		if(common->count!=line_nos){
			puts(common->word);
			printf(" ");
		}
		common=common->next;
	}
	return;	
}


int main(int argc, char *argv[])
{
	FILE *input_file;
	int line_nos;
	list first=NULL; …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I tried to compile it with VC++ 2008 Express and got a lot of warnings. Most of them were about functions that are declared to return an int but return nothing. You should either add return a number or make the functions void.

line 21: you are allocating too little space. list is a pointer and what you want is the size of the struct node. replace list with struct node


line 33: strcmp() does not return NULL -- it returns 0. VOID may or may not be defined as 0, depending on your compiler. strcmp() returns an integer.

line 130: close() is undefined. You probably meant fclose()

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
1>c:\documents and settings\myfolder\desktop\mydocs\c\visual\memory\memory.cpp(57) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

That is a Microsoft-Specific warning message. M$ doesn't like using the standard C style string functions like strlen(), strcpy() etc because they have potential problems of overwriting buffers, which is true because they are dangerous if extra care isn't taken to insure program safety.

If you use the replacement function identified in the warning message then your program will not be able to be compiled by other programs because those replacement functions are not standard functions. If you have to hand in the source code of your assignment to your teacher, then your teacher can't compile it without using the same version of the Microsoft compiler that you used.

My suggestion to students is to ignore that warning message and use #pragma warning(disable: 4996) to prevent the compiler from issuing it -- unless of course your teacher has instructed you to do otherwise.

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

just delete line 4, 5 and 6 because it is defined in windows.h (wincon.h)

>>printf("%d",x.WINAPI);
what is x.WINAPI?

>>Please advice what is wrong with the syntax
Everything. WINAPI is not a data object that can be printed.

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

VC++ 6.0 will work on Vista but you will get a lot of compatability warning messages. VC++ 2008 Express runs perfectly on Vista. So if you are currently using VC++ 6.0 you should upgrade to VC++ 2008.

I use Dev-C++ on Vista. But you may have to add full paths to the directories listed in in Tools --> Compiler Options --> Directories.

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

First you have to learn how to read :) See the Read Me threads at the beginning of this board.

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

why can't the calling function check to see if there are more last names with the same value?

int index = searchLN( <parameters here > );
while( inName[index].getlastname() == targetLastName)
{
    cout << inName[index].getlastname() << " ";
    index++;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

the only c++/CLI compiler (that generates CIL which could run on many platforms) is the one from microsoft. other CLI implementations (like mono) do not provide c++ compiler support.

I think some Borland compilers will do that too.

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

I am on windows.

Which is the compiler most widely used in the industry ?

For MS-Windows, Microsoft compilers are naturally the most widely used by professional programmers because, for one reason, MS-Windows was written by Microsoft compilers. Here is one testimonial to that statement. Professionals rarly use the Express version, which is intended for learning. The Professional version is probably the most popular versions of Visual Studio 2008 series.