error: cannot convert ‘std::basic_string<char>’ to ‘int’ in assignment

Hi, im getting the above error for the following code. Please help me with what i am doing wrong.

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <limits>
#include <stdio.h>
#include <sstream>


using namespace std;
using std::stringstream;
struct rootset {
  double totSize;
  const char *rStrtPtr;
  const char *rEndPtr;
 
  struct generations {
    double totSize;
    const char *genStrtPtr;
    const char *genEndPtr; 
    int numOfGen;
    int genName;
   
    struct object {
      double objSize;
      const char *objStrtPtr;
      const char *objEndPtr;
      string id;
      char markBit;
      char objPtr;
   
  
      struct freeList {
	double freeSpace;
	int flNumb; 
      };
    };
  } generation;
};

int main()
{

  int gen =0;
  cin >> gen;

  rootset* pRootSet = (rootset*)malloc(1200);

  for( i=0; i<gen; i++) {
    stringstream out;
    out << i;
   string s = out.str();
   string foo = "generation";
   
   pRootSet->generation.genName = foo.append(s);  /*Error is here*/
   cout<<"foo: "<<foo<<endl;
  }
}
Last edited on
This code has nested structures. For now it generates name for the generation structure based on the input given by the user.
i am trying to print this answer:

1
2
3
4
5
4
foo: generation0
foo: generation1
foo: generation2
foo: generation3
my bad. I made a mistake here myself. I corrected it.. I declared the genName of type int
Topic archived. No new replies allowed.