#include <iostream>
#include <vector>
using namespace std;
int main()
{
int col[10],i,j=0,num=0,l=0,k=0,len=0;
vector< vector<char> > arr((20),vector<char>(200));
vector<vector <char> >res((20),vector<char>(200));
for(i=0;;i++)
{
cin >>num;
if(num==0)
break;
col[i]=num;
cin >> arr[i][200];
}
for(i=0;;i++)
{
if(col[i]==0)
break;
len=arr[i].size();
while(k!=0)
{
k=j%len-1;
res[i][l]=arr[i][j];
l++;
j=j+3;
}
}
return 0;
}
the vector initialization is char
and valgrind I am getting this
==23649== Memcheck, a memory error detector
==23649== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==23649== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==23649== Command: ./a.out
==23649== HEAP SUMMARY:
==23649== in use at exit: 8,960 bytes in 42 blocks
==23649== total heap usage: 44 allocs, 2 frees, 9,360 bytes allocated
==23649==
==23649== LEAK SUMMARY:
==23649== definitely lost: 0 bytes in 0 blocks
==23649== indirectly lost: 0 bytes in 0 blocks
==23649== possibly lost: 0 bytes in 0 blocks
==23649== still reachable: 8,960 bytes in 42 blocks
==23649== suppressed: 0 bytes in 0 blocks
==23649== Reachable blocks (those to which a pointer was found) are not shown.
==23649== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23649==
==23649== For counts of detected and suppressed errors, rerun with: -v
==23649== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
please help me someone with full check i got this
=24543== 480 bytes in 1 blocks are still reachable in loss record 1 of 3
==24543== at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24543== by 0x401B50: _gnucxx::new_allocator > >::allocate(unsigned long, void const*) (new_allocator.h:104)
==24543== by 0x4019FE: std::Vectorbase >, std::allocator > > >::Mallocate(unsigned long) (in /home/hemanth/a.out)
==24543== by 0x40184C: std::Vectorbase >, std::allocator > > >::Mcreate_storage(unsigned long) (stl_vector.h:181)
==24543== by 0x401594: std::Vectorbase >, std::allocator > > >::Vectorbase(unsigned long, std::allocator > > const&) (stl_vector.h:136)
==24543== by 0x4012B9: std::vector >, std::allocator > > >::vector(unsigned long, std::vector > const&, std::allocator > > const&) (stl_vector.h:297)
==24543== by 0x400DD3: main (main.cpp:9)
==24543==
==24543== 480 bytes in 1 blocks are still reachable in loss record 2 of 3
==24543== at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24543== by 0x401B50: _gnucxx::new_allocator > >::allocate(unsigned long, void const*) (new_allocator.h:104)
==24543== by 0x4019FE: std::Vectorbase >, std::allocator > > >::Mallocate(unsigned long) (in /home/hemanth/a.out)
==24543== by 0x40184C: std::Vectorbase >, std::allocator > > >::Mcreate_storage(unsigned long) (stl_vector.h:181)
==24543== by 0x401594: std::Vectorbase >, std::allocator > > >::Vectorbase(unsigned long, std::allocator > > const&) (stl_vector.h:136)
==24543== by 0x4012B9: std::vector >, std::allocator > > >::vector(unsigned long, std::vector > const&, std::allocator > > const&) (stl_vector.h:297)
==24543== by 0x400E51: main (main.cpp:10)
==24543==
==24543== 8,000 bytes in 40 blocks are still reachable in loss record 3 of 3
==24543== at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24543== by 0x401AC9: _gnucxx::new_allocator::allocate(unsigned long, void const*) (new_allocator.h:104)
==24543== by 0x401942: std::Vectorbase >::Mallocate(unsigned long) (in /home/hemanth/a.out)
==24543== by 0x401728: std::Vectorbase >::Mcreate_storage(unsigned long) (stl_vector.h:181)
==24543== by 0x401416: std::Vectorbase >::Vectorbase(unsigned long, std::allocator const&) (stl_vector.h:136)
==24543== by 0x401D68: std::vector >::vector(std::vector > const&) (stl_vector.h:312)
==24543== by 0x401C98: void std::Construct >, std::vector > >(std::vector >*, std::vector > const&) (stlconstruct.h:83)
==24543== by 0x401B8C: void std::uninitialized_fill_n::uninit_fill_n >, unsigned long, std::vector > >(std::vector >, unsigned long, std::vector > const&) (stl_uninitialized.h:187)
==24543== by 0x401A54: void std::uninitialized_fill_n >, unsigned long, std::vector > >(std::vector >, unsigned long, std::vector > const&) (stl_uninitialized.h:223)
==24543== by 0x4018EC: void std::_uninitializedfill_n_a >, unsigned long, std::vector >, std::vector > >(std::vector >, unsigned long, std::vector > const&, std::allocator > >&) (stl_uninitialized.h:334)
==24543== by 0x401673: std::vector >, std::allocator > > >::Mfill_initialize(unsigned long, std::vector > const&) (stl_vector.h:1214)
==24543== by 0x4012D0: std::vector >, std::allocator > > >::vector(unsigned long, std::vector > const&, std::allocator > > const&) (stl_vector.h:298)