Skip to content

C / C++ / MFC

C, Visual C++ and MFC discussions

This category can be followed from the open social web via the handle c-c-mfc@forum.codeproject.com

111.5k Topics 465.7k Posts
  • C language

    tutorial
    3
    0 Votes
    3 Posts
    12 Views
    CPalliniC
    Read a line, fgets[^] is your friend. If the line read is exactly END than your task is complete: report the line, word and character count. On the other hand, if the line read is not the termination one, then increment the line count, and get the first character (incrementing the character count): if it is a blank then set a flag was_blank = 1; and go on. If it is not a blank then increment the word count and clear the flag: was_blank = 0;. Go on with the next character (if any): increment the character count and if the character is a blank then set was_blank = 1; not a blank then, depending on the was_blank flag increment the word count (or do nothing), eventually clear the flag: was_blank = 0; "In testa che avete, Signor di Ceprano?" -- Rigoletto
  • How to implement variable amount of parameters?

    data-structures tutorial question
    6
    0 Votes
    6 Posts
    11 Views
    C
    " in three months there are 20" Nah, they're on to the next project.... who cares about code maintenance? :) Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.
  • 0 Votes
    1 Posts
    2 Views
    No one has replied
  • C++ non-null pointers

    c++ com question discussion
    3
    0 Votes
    3 Posts
    8 Views
    Mircea NeacsuM
    My thoughts exactly. Seems more trouble than it's worth. Mircea
  • Reorganizing code

    question workspace
    2
    0 Votes
    2 Posts
    3 Views
    L
    There is no simple answer to such a question as the lifetime of a variable will depend on its usage and requirements. You need to analyse your code to decide what is best in each specific case.
  • Compiler academic question - why?

    question
    5
    0 Votes
    5 Posts
    4 Views
    Mircea NeacsuM
    Aren’t we all beginners constantly trying to learn new things? Do you think I saw that error in a book? :laugh: Mircea
  • 0 Votes
    4 Posts
    10 Views
    D
    If you can get Notepad++ working on Linux through Wine, as per [this page](https://itsfoss.com/notepad-plus-plus-linux/), you can record a script in it to do the job. Don't know how difficult it will be to do across multiple files, as far as opening them individually goes, but the script can be assigned a keyboard shortcut to make it easier. You can also use extended characters to search and replace every occurrence without having to trigger the macro for each instance in the file. Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver
  • Jonathan Beaudeau and Iris Amabile Beaudeau are Scammers

    com
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • C code challenge...

    design sysadmin debugging question
    3
    0 Votes
    3 Posts
    4 Views
    CPalliniC
    That is C++, not C. I show you how it could be handled in a similar scenario: #include #include using namespace std; #define STD_DEBUG #ifdef STD_DEBUG #define DBG(txt) cerr << txt #else #define DBG(txt) \ do { \ ostringstream os; \ os << txt; \ string s = os.str(); \ cout << "The debug string: " << s; \ } while (0) #endif int main() { DBG("foobar = " << 42 << "\n"); } "In testa che avete, Signor di Ceprano?" -- Rigoletto
  • 0 Votes
    6 Posts
    12 Views
    J
    No that doesn't help at all. Making it as simple as I can... There is a set (one or more) objects that use the configuration. There is another set (one or more) objects that manage the configuration (lets say read it from a file.) The two sets must not be the same.
  • How to add #include to makefile ?

    help tutorial question
    4
    0 Votes
    4 Posts
    7 Views
    K
    g++ will create pre-compiled headers quite simply: g++ foo.hpp creates a foo.hpp.gch, and the compiler will search for a .gch file when processing a #include directive. If necessary, you can include -x c++-header flags to indicate to the compiler that the named sources are to be treated as header files rather than program source code. Also note that some compiler flags need to match for both PCH and source code. More details here: [Precompiled Headers (Using the GNU Compiler Collection (GCC))](https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html) Keep Calm and Carry On
  • Passing a pointer to object - using template - followup.

    help question c++ tutorial
    14
    0 Votes
    14 Posts
    4 Views
    J
    Member 14968771 wrote: you and everybody else have a choice to ignore it and you are not my mother to criticize my "tone". Ok cool. You're a child and you'll never get help from me in the future. Enjoy your tantrum. Jeremy Falcon
  • xxx_GetProcessIndexFromID error...

    hardware c++ com algorithms debugging
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • 0 Votes
    6 Posts
    12 Views
    J
    BernardIE5317 wrote: whilst examining those utilized in llvm i examined several h header files and found they are not templated and are not merely a declaration but a definition containing code It would of course depend on what they were exactly doing. Been many years but at least way back when a 'template' ended up creating its own source for each usage. Probably necessary because it was not up to the compiler to figure out where overlaps might cause problems. But excluding actual templates then no I am not a fan of putting a lot of code in header files. BernardIE5317 wrote: much more knowledgeable/experienced/clever/intelligent than myself Perhaps...Or they just have a high opinion of their own opinion.
  • Compilers

    csharp c++ hardware performance question
    18
    0 Votes
    18 Posts
    26 Views
    B
    in case you have not yet read it the page below at Wikipedia seems informative History of compiler construction - Wikipedia[^]
  • Clang/LLVM support in Visual Studio projects

    c++ visual-studio csharp com tutorial
    9
    0 Votes
    9 Posts
    3 Views
    J
    Well that is nice.
  • English , please....

    8
    0 Votes
    8 Posts
    3 Views
    L
    Gerry Schmitz wrote: You are a troll. I tend to agree; he certainly has history. Also complains of being thrown out of other forums for "asking too many questions", but I suspect the real reason is not that.
  • 0 Votes
    12 Posts
    22 Views
    C
    oh well, suit yourself. Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.
  • Visitors count in decreasing sequence

    c++ com question
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Visitors count in decreasing sequence

    c++ com question
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied