User forums > General (but related to Code::Blocks)
Size_type Erro
(1/1)
williampool:
Hello,
I am new to Code::Blocks (and C++) and have been working through examples from C++ All-In-One for dummies, 4th Edition. The code below and several other codes I have tried to run keep having the following error:
error: conversion to 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]|
The code for the warning above can be found below. The build error was referencing the following line: InkLevelPercent = InkLevelPercent - words.length();
In another code I tried to run, I received the following similar error:
error: conversion to 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long long unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]|
The build error was referencing the following line in that code (I can post that code as well if needed):
int randomIndex = rand() % words.size();
Is there something obvious I may be missing? Browsing through Google I kept seeing references to size_t but wasn't sure if that was applicable, and if so, how to change the code to correct the issue.
Miguel Gimenez:
Copy of a post in Reddit.
Waiting for the spam link...
Navigation
[0] Message Index
Go to full version