example output:


Meter number is: 124123ABC231


"what should i use to define something like that....


TurboC newbie here...

a character array or std::string

can you give a sample how to do it...?

char mnumber[255];
printf("Enter an item number\n");
fgets(mnumber,sizeof(mnumber), stdin);
if( mnumber[strlen(mnumber)-1] == '\n')
   mnumber[strlen(mnumber)-1] = '\0';
printf("Meter number is: %s\n", mnumber);

Or if you want the c++ version

std::string mnumber;
cout << "Enter an item number\n";
getline(cin,mnumber);
cout << "Meter number is: " << mnumber << '\n';
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.