Result is empty/nothing

Why the result is empty/nothing displayed?

main.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//....
#include <string>
#include "decry loop.h"
#include <stdlib.h>

int main()
{
string p;
int q = 0;
int o = 6;
cout << "Sentence: ";
cin.ignore();
getline (cin,p); //*Introduce "00100 "
char h = (p.length() / 6);
cout<<"Result: ";
for (int i; i < h; i++) //doing the loop 1 time or 2 if theres 12 characters!
{
std::string f6de = p.substr(q, o); //Detect first 6 character with white spaces
dloop(f6de, dlr); //the loop!
q += 6; //Going to the next part
o += 6; //Going to the next part, something like if i have "00100 01010 "
}
cout<<dlr;
return 0;
}


dloop.h:
1
2
3
4
5
6
7
8
9
10
#ifndef DECRY_LOOP_H
#define DECRY_LOOP_H
#include<iostream>
#include<string>
#include<stdlib.h>

using namespace std;
void dloop(std::string f6de, string& dlr);

#endif 


dloop.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include "decry loop.h"
#include <string>

using namespace std;

void dloop(std::string f6de, string& dlr)
{
if(f6de == "00100 ")
{
dlr +='A';
}
else if(f6de == "01010 ")
{
dlr +='B';
}

return 0;


at the main.cpp: when cout<<dlr; is displayed nothing? I dont understand and i tryed to fix this and anything that i tryed dosent worked, please help me! Thanks in advance!
Last edited on
You forgot to initialize i.
here? for (int i; i < h; i++) its maked "IN"
Yes, that's it.
I already maked it, look at first post, no difference :(
**I will be afk for 2 hour**, i hope some1 will find my problem :(, i will enter on phone, but idk if i can see/reply!
Last edited on
Initialize means setting a starting value for a variable. In your program I guess you want to initialize i to zero.

 
for (int i = 0; i < h; i++)
Wow, such a small thing //*facepalm**
Thank you //*#I_still_face_palm_myself*

EDIT: Idk why i need-ed to int i = 0 because in other of my code's it was worked without = 0 , now its not important anymore :)

Also, just an question, there will be an C++16 (2016)??? I'm curious :O
Last edited on
Topic archived. No new replies allowed.