Jump to content


Check out our Community Blogs

bexita

Member Since 17 Oct 2011
Offline Last Active Dec 26 2011 05:24 PM
-----

Posts I've Made

In Topic: Calculate an expression using stack

27 November 2011 - 05:07 PM

I changed but the result is still wrong . :confused:

In Topic: Searching in linked list problem!

09 November 2011 - 07:40 AM

Still error ,

I think the error comes from VoidPtr target , but i am not sure how to fix..

In Topic: Help on seach element in array using poitner C++

06 November 2011 - 06:23 PM

You return out of the method on the first comparison, which forces you out of the loop to check the next. You should use a temporary variable to store if you found it.


Hi , Do you mean like this? but it still doesnt work for me..

bool Search(char *a, int size, char *which) // Search element 
{
	
	Ptr b= a;
	int flag =0;
	for (int i=0;i <size;i++)
	{
	
		if (b[i]==toupper(*which))
		
		{
			flag =1;
				
			return true;
		}
			
			if(flag==1)
			{	 
		
			return true;
	
			}
			else
			{
			return false;
			}
	
	}
}

:crying:

In Topic: How to read text file into array in C++?

28 October 2011 - 07:27 AM

struct student{
int k_value;
char name[200];
int no_module;
char module_code[200]
};

//Storing info in the txt file
while (afile >> s[i].k_value)  // a random student no stored in struct
	{		
			afile.getline (s[i].name,200,'\n');
			afile >>s[i].no_module;// till here its ok for output text file.

			int no= s[i].no_module; 
			for (int j=0;j<no; j++) 
			{
				afile >> s[i].module_code[j]; // it displayed wrong in the output file
				
			}
		
		
	i++;
			
	}

I still stuck at storing the info of this text file. Pls advise.
THanks

In Topic: How to read text file into array in C++?

27 October 2011 - 03:56 AM

Hi , my code looks like this but it displayed wrongly:
while (afile >> s[i].k_value)
	{
		
			
			afile >> s[i].name;
			afile >>s[i].no_module;

			int no= s[i].no_module;
			for (;i<no; i++)
			{
				afile.getline(s[i].m_code, MAX,'\n');
				
			}
		
		
	i++;
			
	}

whats wrong with this code of store?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download