简体   繁体   中英

Invalid octal format encountered in function passing parameter

In main.cpp

classObject.sendTime(23,10,08);

In class.cpp

void CClassName::sendTime(unsigned short hh, unsigned short mm, unsigned short ss)
{//some operation}

In main.cpp the line get an error "Invalid octal format encountered"

In case of classObject.sendTime(10,05,02); the code compiles and executes.

What could be a possible reason for this? Please help

Any integer literal starting with digit 0 followed by other digits is considered to be octal, ie base 8. The digits following the 0 must be valid octal digits, which excludes 08 , since the only valid digits in base 8 are [0,7] . Just use 8 .

See this reference for octal and other integer literals .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM