Skip to content

Using snprintf instead of sprintf for filenames #108

Description

@jwreep

This is relatively minor, but it clutters the compiler output. Recent C++ versions are now returning warnings for sprintf, which can lead to memory leaks, and recommend using snprintf instead. As a result, when compiling HYDRAD, there are lots of warnings like this:

WARNING: ../source/mesh.cpp:1866:1: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  
Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. 
[-Wdeprecated-declarations]
sprintf( szPhysicalFilename, "Results/profile%i.phy", iFileNumber );

The code doesn't have any memory leaks from what I can tell, but it would be nice to clear away these warnings at some point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions