Why doesn't this work?

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

void L(int valoare, int bin[], int poz);
void G(int valoare, int bin [], int poz);
void R(int valoare, int bin [], int poz);


void main ()
{
char codDat[10], denumire [21];
cout << "Introduceti denumirea produsului (max. 21 de caractere): ";
cin >> denumire;
cout << "Introduceti codul produsului (max. 9 cifre): ";
cin >> codDat;
int lungime = strlen(codDat);
int i = 0;
while (codDat[i]>= '0' && codDat[i]<= '9')
i++;
if(i != lungime)
{
cout << "Cod eronat: " << codDat << endl;
return;
}
char sirSapte[9]= "";
if (lungime < 9)
{
int j;
for (j=0; j<9-lungime; j++)
sirSapte[j]= '7';
sirSapte[j]='\0';
}

char codRO[] = "594";
char ean13[13];
strcpy(ean13, codRO);
strcat(ean13, sirSapte);
strcat(ean13, codDat);
cout << "Primele 12 caractere sunt: " << ean13 << endl;
int nean13[13];
for (i=0; i<12; i++)
nean13[i]= ean13[i] - '0';
cout << "Valorile intregi ale caracterelor sunt: ";
for (i=0; i<12; i++)
cout << nean13[i];
cout << endl;
double s1, s2;
s1=s2=0;
for (i=0; i<12; i= i+2)
{
s1=s1+nean13[i];
s2=s2+nean13[i+1];
}
int S;
S= s1+3*s2;
nean13[12]= 10-S%10;
cout << "Sirul este : ";
for (i=0; i<13; i++)
cout << nean13[i];
cout << endl;
int b[95]; // se codifica inceputul:101
b[0]=b[2]=1;
b[1]=0;// se codifica prima parte a codului(6 caractere, nean13[1] la nean13[6])
L(nean13[1], b, 3);
G(nean13[2], b, 10);
G(nean13[3], b, 17);
L(nean13[4], b, 24);
L(nean13[5], b, 31);
G(nean13[6], b, 38);
// se codifica zona de separare din mijloc 01010;
b[45]=b[47]=b[49]=0;
b[46]=b[48]=1;
// se codifica a doua parte a codului de la nean13[7] la nean13[12];
// pentru toate se apeleaza functia R();
for(i=0; i<6; i++)
R(nean13[7+i], b, 50+i*7);
// se codifica partea finala a codului, 101;
b[92]=b[94]=1;
b[93]= 0;
cout << "Sirul de 95 de cifre binare este: ";
for (i=0; i<95; i++)
cout << b[i];
fstream cod;
cod.open("cod.html", ios::out);
cod << "<!DOCTYPE html>" << endl;
cod << "<html>" << endl;
cod << "<body>" << endl;
cod << "<svg height=\"50\" width=\"200\">" << endl; // 2 pixeli pentru fiecare bara
int pozx= 10; //de la acest x incep trasarea
for (i=0; i<95; i++)
{
if (b[i]== 1) // se traseaza o linie
cod << "<line x1=\""<< pozx << "\"y1=\"20\" x2=\"" << pozx << "\" y2=\"50\" style=\"stroke:rgb(0,0,0); stroke-width:2\" />" << endl;
pozx= pozx+2; // avans cu 2 pixeli, indiferent daca s-a trasat sau nu
}
cod << "</svg>" << endl;
cod << "</body>" << endl;
cod << "</html>" << endl;
cod.close();
}

This part:

<line x1=\""<< pozx << "\"y1=\"20\" x2=\"" << pozx << "\" y2=\"50\" style=\"stroke:rgb(0,0,0); stroke-width:2\" />

does not appear in the page source of the html created. why?

Last edited on
Please edit your post and make sure your code is [code]between code tags[/code] so that it has line numbers and syntax highlighting, as well as proper indentation.

Have you tried printing out the values of your b array to see what they are at that point in the code? How do you know that one of them will be 1?
Topic archived. No new replies allowed.