void graph::fillTable()
{
ifstream fin;
char X;
int slot=0;
fin.open("data.txt");
while(fin.good()){
fin>>Gtable[slot].Name;
fin>>Gtable[slot].Out;
cout<<Gtable[slot].Name<<endl;
for(int i=0; i<=Gtable[slot].Out-1;i++)
{
**//cant get here**
fin>>X;
cout<<X<<endl;
Gtable[slot].AdjacentOnes.addFront(X);
}
slot++;
}
fin.close();
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码,基本上它完全符合我的要求但是当文件不再好的时候它会继续阅读.它会输入并输出我正在寻找的所有东西,然后当文件结束时,fin.good()显然不会返回false.这是文本文件.
A 2 B F
B 2 C G
C 1 H
H 2 G I
I 3 A G E
F 2 I E
Run Code Online (Sandbox Code Playgroud)
这是输出
A
B
F
B
C
G
C
H
H
G
I
I
A
G
E
F
I
E
Segmentation fault
Run Code Online (Sandbox Code Playgroud)
-
这是Gtable的类型.
struct Gvertex:public slist …Run Code Online (Sandbox Code Playgroud) 我只是想跟随android dev上的示例代码来扩展活动中的片段.我有一个更复杂的项目,我正在工作,但我得到的错误与这里的简单错误相同.谁能指出我正确的方向?
扩展片段的类
package com.example.fragtest;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FragOne extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container, Bundle savedInstanceState){
return inflater.inflate(R.layout.activity_main, container,false);
}
}
Run Code Online (Sandbox Code Playgroud)
扩展FragmentActivity的类
package com.example.fragtest;
import android.os.Bundle;
import android.view.Menu;
import android.support.v4.app.FragmentActivity;
public class MainActivity extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
片段所在的xml
<?xml version="1.0" …Run Code Online (Sandbox Code Playgroud) 在viewDidLoad()下面,设置我的财产self.textToAnalyze在结果property之中nil在调试器,而直接设置属性使用_textToAnalyze表明,该属性不再为零.为什么是这样?
//
// TextStatsViewController.m
// colorSwitcher
#import "TextStatsViewController.h"
@interface TextStatsViewController ()
@property (weak, nonatomic) IBOutlet UILabel *colorfulCharactersLabel;
@property (weak, nonatomic) IBOutlet UILabel *outlinedCharactersLabel;
@end
@implementation TextStatsViewController
-(void)setTextToAnalyze:(NSAttributedString *)textToAnalyze
{
}
-(void)viewDidLoad
{
_textToAnalyze=[[NSAttributedString alloc] initWithString:@"test" attributes:@{NSForegroundColorAttributeName : [UIColor greenColor],NSStrokeWidthAttributeName :@-3}]; //setting it here with the underscore shows that this property is not nil in the debugger
//self.textToAnalyze=[[NSAttributedString alloc] initWithString:@"test" attributes:@{NSForegroundColorAttributeName : [UIColor greenColor],NSStrokeWidthAttributeName :@-3}]; //setting it here with the accessor …Run Code Online (Sandbox Code Playgroud) 我在以下位置找到了我的 JDK /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk
我的 .bash_profile 中有这个
export JAVA_HOME=/Library/Java
export PATH=$JAVA_HOME/bin:$PATH
Run Code Online (Sandbox Code Playgroud)
我已经保存了我的更改 source .bash_profile
现在当我尝试跑步时 sudo apt get install gcc
我收到这个错误
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/apt" (-1)
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?
当我运行它时,它将有时打印出一个空终止字符.它大部分时间都会打印,而且可能是打印字符的1/5.
void cryptogram::Encrypt(){
cout<<"encrypt"<<endl;
char Alphabet[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
fin.open("original.txt");
cout<<"file opened";
if(!fin)
{
cout<<"No file exists"<<endl;;
}else{
while(fin>>tempS){
len=tempS.length();
int a=0;
for(int j=0;j<len;j++){
for(a;a<=26;a++){
tempS[j]=toupper(tempS[j]);
if(tempS[j]!=Alphabet[a]){//while two characters arent equal
//if the characters arent equal...a is incremented, to see if the character from the word is equal to the next letter in the alphabet
}else{
cout<<Crypto[a];
//crypto is an array of char filled with letters that are used to encrypt the message
if(j!=len){ //if the word still has more characters
j++;
a=0; …Run Code Online (Sandbox Code Playgroud) 我有来自用户的字符串...... 1,2,3具有任意数量的数字.我想要做的是将数字替换为数组中每个数字的indeces处的相应值.所以说我的阵列有[tom] [jerry] [sue].当我正在处理时,我希望我的字符串看起来像汤姆,杰瑞,起诉.我应该使用grep吗?庆典?
c++ ×2
android ×1
bash ×1
encryption ×1
fstream ×1
gcc ×1
gem ×1
grep ×1
ios ×1
java ×1
macos ×1
null ×1
objective-c ×1
properties ×1
shell ×1
termination ×1