变量C ++的问题 [英] Problems With Variables C++

查看:75
本文介绍了变量C ++的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,



我遇到变量问题,而调试变量会在每一行后一次又一次地自动分配给一些随机大值,帮我解决这个PLZ



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

char * Line_Address(字符串路径,int Delimer,int行)
{
char * keys;
char * temp;
temp = new char [70];
temp [69] =''\''';
bool Loopbrk = false;
int iCounter = 0,iDelimer = 0,i = 0,count = 0;
ifstream myfile(path);
char键击;
while(myfile.good())
{
myfile.get(keystroke);
if(keystroke ==''!'')
iCounter ++;
while(iCounter == line)
{
myfile.get(keystroke);

if(keystroke ==''$'')
iDelimer ++;
while(iDelimer == Delimer)
{
myfile.get(keystroke);

temp [i] =按键;
i ++;
if(keystroke ==''$'')
{
Loopbrk = true;
休息;
}
}
if(Loopbrk == true)
break;
}
if(Loopbrk == true)
break;
}
int size = strlen(temp);
for(int i = 0; i< size; i ++)
if((temp [i]> = 48&& temp [i]< = 57)||(temp [i ]> = 97&安培;&安培;温度[1] - = 122)||(TEMP [I]> = 65&安培;&安培;温度[1] - ; = 90)||温度[I] == 32)
count ++;
keys = new char [count + 1];
for(int i = 0; i< count; i ++)
keys [i] = temp [i];
keys [count] =''\''';
delete [] temp;
返回键;
}
int T_Delimer(字符串路径)
{
int iDelimer = 0;
char keystroke ='''';
ifstream myfile(path);
while(myfile.good())
{
while(keystroke!=''!'')
{
myfile.get(keystroke);
if(keystroke ==''$'')
iDelimer ++;
}
休息;
}
返回iDelimer;
}
void main()
{
string keystroke [10];
int jpg = 0,gif = 1,Delimers = T_Delimer(student.txt);;
char key;
for(int i = 0; i< Delimers; i ++)
{
keystroke [i] = Line_Address(student.txt,i,gif);
}
fstream myfile(student.txt);
while(myfile.good())
{
myfile.get(key);
if(key ==''!'')
jpg ++;
if(jpg == gif)
{
fstream(student.txt,ios :: in);
myfile<<;
}
}
myfile.close();
}





////////////////student.txt/// ///////////



 l114443 $ Talha Jamil $ samsung $ 12 $ 17 $ 2004 $ UnderGraduate $! 
l114445 $ Kamran Javed $ jannat123 $ 12 $ 12 $ 2009 $ UnderGraduate $!
l114093 $ Imran Khan $ pluto123 $ 11 $ 4 $ 2009 $ UnderGraduate $!
l114444 $ Jamil Ahmed $ origin123 $ 11 $ 12 $ 2009 $ UnderGraduate $!
l114606 $ Zain Malik $ samsung $ 9 $ 16 $ 2009 $毕业生$!
l114441 $ Saad Kamran $ samsung $ 11 $ 4 $ 2004 $ Graduate $!

解决方案

'')
iDelimer ++;
while(iDelimer == Delimer)
{
myfile.get(keystroke);

temp [i] =按键;
i ++;
if(keystroke ==''


'')
{
Loopbrk = true;
休息;
}
}
if(Loopbrk == true)
break;
}
if(Loopbrk == true)
break;
}
int size = strlen(temp);
for(int i = 0; i< size; i ++)
if((temp [i]> = 48&& temp [i]< = 57)||(temp [i ]> = 97&安培;&安培;温度[1] - = 122)||(TEMP [I]> = 65&安培;&安培;温度[1] - ; = 90)||温度[I] == 32)
count ++;
keys = new char [count + 1];
for(int i = 0; i< count; i ++)
keys [i] = temp [i];
keys [count] =''\''';
delete [] temp;
返回键;
}
int T_Delimer(字符串路径)
{
int iDelimer = 0;
char keystroke ='''';
ifstream myfile(path);
while(myfile.good())
{
while(keystroke!=''!'')
{
myfile.get(keystroke);
if(keystroke ==''


'')
iDelimer ++;
}
休息;
}
返回iDelimer;
}
void main()
{
string keystroke [10];
int jpg = 0,gif = 1,Delimers = T_Delimer(student.txt);;
char key;
for(int i = 0; i< Delimers; i ++)
{
keystroke [i] = Line_Address(student.txt,i,gif);
}
fstream myfile(student.txt);
while(myfile.good())
{
myfile.get(key);
if(key ==''!'')
jpg ++;
if(jpg == gif)
{
fstream(student.txt,ios :: in);
myfile<<;
}
}
myfile.close();
}





////////////////student.txt/// ///////////



 l114443 


hey,

I am having problem with variables, while debugging variable is automatically assigned to some random large value again and again after each line, Help me out of this plz

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

char* Line_Address(string path,int Delimer,int line)
{
	char* keys;
	char* temp;
	temp=new char[70];
	temp[69]=''\0'';
	bool Loopbrk=false;
	int iCounter=0,iDelimer=0,i=0,count=0;
	ifstream myfile(path);
	char keystroke;
	while(myfile.good())
	{
		myfile.get(keystroke);
		if(keystroke==''!'')
			iCounter++;
		while(iCounter==line)
		{
			myfile.get(keystroke);
			
			if(keystroke==''$'')
				iDelimer++;
			while(iDelimer==Delimer)
			{
				myfile.get(keystroke);
				
				temp[i]=keystroke;
				i++;
				if(keystroke==''$'')
				{
					Loopbrk=true;
					break;
				}
			}
			if(Loopbrk==true)
				break;
		}
		if(Loopbrk==true)
				break;
	}
	int size=strlen(temp);
	for(int i=0;i<size;i++)
		if((temp[i]>=48&&temp[i]<=57)||(temp[i]>=97&&temp[i]<=122)||(temp[i]>=65&&temp[i]<=90)||temp[i]==32)
			count++;	
	keys=new char[count+1];
	for(int i=0;i<count;i++)
		keys[i]=temp[i];
	keys[count]=''\0'';
	delete []temp;
	return keys;
}
int T_Delimer(string path)
{
	int iDelimer=0;
	char keystroke='' '';
	ifstream myfile(path);
	while(myfile.good())
	{
		while(keystroke!=''!'')
		{
			myfile.get(keystroke);
			if(keystroke==''$'')
				iDelimer++;
		}
		break;
	}
	return iDelimer;
}
void main()
{
	string keystroke[10];
	int jpg=0,gif=1,Delimers=T_Delimer("student.txt");;
	char key;
	for(int i=0;i<Delimers;i++)
	{
		keystroke[i]=Line_Address("student.txt",i,gif);
	}
	fstream myfile("student.txt");
	while(myfile.good())
	{
		myfile.get(key);
		if(key==''!'')
			jpg++;
		if(jpg==gif)
		{
			fstream("student.txt",ios::in);
			myfile<<" ";
		}
	}
	myfile.close();
}



////////////////student.txt//////////////

l114443$Talha Jamil$samsung$12$17$2004$UnderGraduate$!
l114445$Kamran Javed$jannat123$12$12$2009$UnderGraduate$!
l114093$Imran Khan$pluto123$11$4$2009$UnderGraduate$!
l114444$Jamil Ahmed$origin123$11$12$2009$UnderGraduate$!
l114606$Zain Malik$samsung$9$16$2009$Graduate$!
l114441$Saad Kamran$samsung$11$4$2004$Graduate$!

解决方案

'') iDelimer++; while(iDelimer==Delimer) { myfile.get(keystroke); temp[i]=keystroke; i++; if(keystroke==''


'') { Loopbrk=true; break; } } if(Loopbrk==true) break; } if(Loopbrk==true) break; } int size=strlen(temp); for(int i=0;i<size;i++) if((temp[i]>=48&&temp[i]<=57)||(temp[i]>=97&&temp[i]<=122)||(temp[i]>=65&&temp[i]<=90)||temp[i]==32) count++; keys=new char[count+1]; for(int i=0;i<count;i++) keys[i]=temp[i]; keys[count]=''\0''; delete []temp; return keys; } int T_Delimer(string path) { int iDelimer=0; char keystroke='' ''; ifstream myfile(path); while(myfile.good()) { while(keystroke!=''!'') { myfile.get(keystroke); if(keystroke==''


'') iDelimer++; } break; } return iDelimer; } void main() { string keystroke[10]; int jpg=0,gif=1,Delimers=T_Delimer("student.txt");; char key; for(int i=0;i<Delimers;i++) { keystroke[i]=Line_Address("student.txt",i,gif); } fstream myfile("student.txt"); while(myfile.good()) { myfile.get(key); if(key==''!'') jpg++; if(jpg==gif) { fstream("student.txt",ios::in); myfile<<" "; } } myfile.close(); }



////////////////student.txt//////////////

l114443


这篇关于变量C ++的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆