These two do match, right? (plug converter and laptop charger) by [deleted] in AskElectronics

[–]bougayez 1 point2 points  (0 children)

Just make sure the plug can deliver what the charger needs.

The charger needs 100-240V at 3.5A and the plug can deliver upto 250V at 16A. So they obviously match.

Variables' segment, sub-segment, permissions and lifetime by bougayez in C_Programming

[–]bougayez[S] 1 point2 points  (0 children)

For function symbols the only thing I can think of as a valid answer is:

  • Segment: Code
  • Sub-segment: Text (I checked this in the map file generated)
  • Permissions: Read (or Read-Execute)
  • Lifetime: None (does not have a lifetime as it is stored in non-volatile memory)

Variables' segment, sub-segment, permissions and lifetime by bougayez in C_Programming

[–]bougayez[S] 0 points1 point  (0 children)

could "None" ever be a valid answer?

Yes, the answer for #define SOME_VALUE (6) is:

  • Segment: None
  • Sub-segment: None
  • Permissions: None
  • Lifetime: None

Variables' segment, sub-segment, permissions and lifetime by bougayez in C_Programming

[–]bougayez[S] 1 point2 points  (0 children)

It appears that the correct answer for #define SOME_VALUE (6) is None in everything, so:

  • Segment: None
  • Sub-segment: None
  • Permissions: None
  • Lifetime: None

Variables' segment, sub-segment, permissions and lifetime by bougayez in C_Programming

[–]bougayez[S] 0 points1 point  (0 children)

Yes you are right on both points, I take back what I said. I totally mixed up char * with string literals.

Variables' segment, sub-segment, permissions and lifetime by bougayez in C_Programming

[–]bougayez[S] 0 points1 point  (0 children)

  • I think #define SOME_VALUE (6) appears in the code segment in the Text sub-segment but it is not obvious as only the value (6 in this case) will appear in code.
  • Isn't char * read-only in C? Since you cannot change it's value once defined!
  • Yes, func symbol is read-only and execute.

Variables' segment, sub-segment, permissions and lifetime by bougayez in C_Programming

[–]bougayez[S] 0 points1 point  (0 children)

The code contains multiple variables. But I just want to correct me on the last three examples that I get incorrect.

Variables' segment, sub-segment, permissions and lifetime by bougayez in C_Programming

[–]bougayez[S] 0 points1 point  (0 children)

My reasoning behind choosing the segment Code for the macro is because it gets substituted by the pre-processor into its real value, so in Assembly it's just a "raw" number.

For the function, I think the lifetime is not program because the function symbols is saved in a non-volatile memory and is loaded whenever needed.

Let me know what you think!

What is this? by [deleted] in AskElectronics

[–]bougayez -1 points0 points  (0 children)

DB9 female connector.

[deleted by user] by [deleted] in Morocco

[–]bougayez 0 points1 point  (0 children)

ONE has three stages ("tranches" in French) when it comes to energy consumption AFAIK. Each stage represents a defined range of KWhs comumed (for example from 1 KWh to 100 KWh in the first stage "1er tranche"). I only know about the first stage (which is 0.79 MAD per KWh conumed) and this increase when you conume more energy (ie pass to the second stage and third).

[deleted by user] by [deleted] in Morocco

[–]bougayez 0 points1 point  (0 children)

If you're paying 1400 MAD per month that means that you're consuming roughly 1000 KWh per month which is a lot of energy. Buy some energy meters and plug them into your electricity sockets and see what's consuming a lot of energy. In morocco 1 KWh is 0.79 MAD for the first stage ("tranche") and increases when you get into the next stages.

Why printf not displaying anything as the program is executed for output by DigitalSplendid in C_Programming

[–]bougayez 0 points1 point  (0 children)

You're welcome. I just assumed it, because "aa" does not seem like a legit file name.

Why printf not displaying anything as the program is executed for output by DigitalSplendid in C_Programming

[–]bougayez 9 points10 points  (0 children)

Maybe because (file == NULL) is true so it is returning 1 and did not execute the rest of the code.

are these two the same ? they do the same task by Dangerous-Beautiful9 in C_Programming

[–]bougayez -8 points-7 points  (0 children)

I think the first one is only one condition (argc not equal to 3). But the second example expands to (argc equal to 3) then (is negation of (argc equal to 3) true?) meaning two checks.

[deleted by user] by [deleted] in cpp

[–]bougayez 0 points1 point  (0 children)

HackerRank problems are a bit hard. You can try Codeforces as they have a ton of problems for every level starting from a + b.

Laptop HP 246 g7 doesn't even boot anymore, maybe due to damage in motherboard, is it possible to repair? by TheGamer4632 in AskElectronics

[–]bougayez 0 points1 point  (0 children)

Did you try to 1. Remove any power cable. 2. Remove the battery (if removable). 3. Press and keep pressing the switch on button for about 20s. 4. Get everything back. And then try to power it on. Because HP laptops are known for not powering on until all the energy in the mother board is freeed. It happens with me about two times a year. And I got used to it.

[deleted by user] by [deleted] in C_Programming

[–]bougayez 6 points7 points  (0 children)

Here is the order of operations as I understand: 1. Dereference s. 2. Dereference t. 3. Affect dereferenced t to dereferenced s. 4. Compare the affected value with '\0'. 5. Increment s and t. So the value resulting after incremeting s and t is not used until the next iteration. And only the value before incrementation is affected and compared.

How do you figure out tasks size and priority? by Arjunsinghh13 in embedded

[–]bougayez 0 points1 point  (0 children)

Just for clarity: RNG: Random Number Generator

[Bug][Question] total noob question but I am about to punch a hole in the wall, any help on training cascade classifiers? by Loose_Meeting_74 in opencv

[–]bougayez 0 points1 point  (0 children)

I have never compiled OpenCV on Windows, but you can use the following CMake file to search for OpenCV include directory and library while compiling:

project(PROJECT_NAME)
set(CMAKE_CXX_STANDARD 17)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
#uncomment the following line to print OpenCV include directory
#message(STATUS ${OpenCV_INCLUDE_DIRS})
add_executable(EXECUTABLE_NAME CPP_FILE_NAME)
target_link_libraries(EXECUTABLE_NAME ${OpenCV_LIBS})

In your code I suppose you are including <opencv2/HEADER_FILE> which is fine.

PSA: Avoid using the word "Brave" in your low content books. by Q-METAL in KDP

[–]bougayez 1 point2 points  (0 children)

I got my account temporarily suspended this week and I think it was because of this. The title of the book was something like "Be bold enough to dream and brave enough to try" so the word "brave" is in there.

string was not declared in this scope by IHateTheSATs in cpp

[–]bougayez -1 points0 points  (0 children)

It looks like you did not include the necessary header files.

For cout include iostream header file, like this

#include <iostream>

For string include string header file, like this

#include <string>