1,288 Posted Topics

Member Avatar for Amoula_1

http://www.cplusplus.com/doc/tutorial/files/ Halfway down: "Reading from a file can also be performed ..."

Member Avatar for Moschops
0
59
Member Avatar for markdean1989

Sounds like it doesn't know what kind of object Class_name is. Where did you tell it that Class_name is a type of a class?

Member Avatar for deceptikon
0
378
Member Avatar for complete

While I am not familiar with silverlight, I look at this code, and I see where you create the wstring object named `wsTransfer`, and then you make `wpszInput` point at that empty string, and then you set the text in `m_pColNum3` with that empty string. At which point is the …

Member Avatar for complete
0
881
Member Avatar for markdean1989

I would be remiss if I did not point you at this: https://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful I would go so far as to say never use `rand()`, even in toy programs just for fun (because you might as well practice not using `rand()` to reduce the chance of ever using it accidentally).

Member Avatar for rubberman
0
637
Member Avatar for Fernando_7

To iterate through a string is to conduct some operation on each char in turn. So get the string: `string value = "feeenhpoorilumayngtumseatsdmepotositnsfrlerruepsrennurdaorantiedbeunrtioradarahe";` and then go through every char in turn for (int i =0; i < value.length(); ++i) { char currentChar = value[i]; // do something with the char …

Member Avatar for Petcheco
0
106
Member Avatar for ramonlarodo

You seem to have made this more complicated than it should be. In the following code, so long as the mutex named `mtx` is shared by all threads, each thread will wait to take the mutex, output `_printMe`, release the mutex. Each thread will output `_printMe` repeatedly; `repcout` times. There …

Member Avatar for Moschops
0
120
Member Avatar for Mayukh_1

See `Firstdata`? Whatever that is, you're defining it in list.cpp and again in main.cpp This is bad. Only define it in one file.

Member Avatar for Mayukh_1
0
131
Member Avatar for hadisur_rahman

The first time a is shown on screen is when you call the function `d.show_a();` The second time a is shown is when you call `d.display();`

Member Avatar for Hassan_12
0
252
Member Avatar for hadisur_rahman

If you're going to write this in C++, which you clearly already are, don't use a char array to store the input. Use a C++ std::string, from the `<string>` header.

Member Avatar for Moschops
0
4K
Member Avatar for Petcheco

#include <math.h> #include <cmath> `cmath` is the C++ header that is to be used in place of the C header `math.h`. So just use `cmath`.

Member Avatar for Petcheco
0
280
Member Avatar for Abdul_32

` total += float read_input( a,b , c ,d,e );` Why does this line of code contain the word `float`? Also, inside the funciton `calculate_average`, the following variables do not exist; `a`, `b`, `c`, `d`, `e`. So you cannot use them in this function call. That's OK, though, because the …

Member Avatar for deceptikon
0
2K
Member Avatar for vjkmr

You can just ask your compiler. #include <iostream> #include <typeinfo> int main() { int a; long int b; float c; double d; std::cout << typeid(a + b - c * d).name() << std::endl; }

Member Avatar for deceptikon
0
94
Member Avatar for it@61@sec

Typically, -pthread would be one of your LIBS, but you don't seem to have one of those. I'd be tempted to add `LIBS = "-pthread"` at the top, and `${LIBS}` to the compile line. CC is your compiler. Somewhere, presumably, that's being set to gcc. You may have environment variables …

Member Avatar for it@61@sec
0
2K
Member Avatar for tentrabyte

> i am ask to create a program that will defined function that will do the same strcpy You haven't defined any functions. You're supposed to be defining a function that does the same as strcpy. Where is your function to do the same as strcpy?

Member Avatar for Moschops
0
229
Member Avatar for PETRICIAMARYMALLIGA A
Member Avatar for Moschops
0
44
Member Avatar for phony

> I try to make program convert decimal to binary but, it adds the decimal number again. You put the decimal number in the stack, and then you put some other numbers on the stack, and then you output the entire stack. What's at the bottom of the stack? The …

Member Avatar for tinstaafl
0
959
Member Avatar for zxz

You're also using `printf` incorrectly. When you are printing out the value of an int, printf does not want the address of that int. It wants the int itself. `printf("%d", &rNumber);` is wrong. `printf("%d", rNumber);` is right.

Member Avatar for zxz
0
3K
Member Avatar for adnan_6

Looks like you're trying to execute the library file. That's not how programs work. You run an executable (the program you built that contains a `main` function) and that program calls functions from this library.

Member Avatar for adnan_6
0
345
Member Avatar for Mica_1

If the numbers can range from 0000 to 9999, you can do it quite simply. Get string. Count number of letters. If not 4, bad. Use string function for this. Get first letter. Check it is a character from the set '0' to '9'. if not, bad. Use isdigit fucntion …

Member Avatar for rubberman
0
106
Member Avatar for Pokenerd**

You generate one random number and then you use that same number for your whole program. Is that what you meant to do?

Member Avatar for Moschops
0
287
Member Avatar for AQ

` char x;` If you want the user to enter a string, shouldn't x be a string rather than a single `char`? ` my_str.find("x");` You appear to be searching for the letter x. Shouldn't you be searching for the string that the user entered? You also need to do something …

Member Avatar for David W
0
323
Member Avatar for studyabroad

If you pay attention to your code, when you set a pointer to NULL, when you come back to it later you can tell that you definitely meant for this pointer to not be pointing at anything right now, and you can make sure not to accidentally use it. That's …

Member Avatar for rubberman
0
123
Member Avatar for Syed Ammar
Member Avatar for Erica_2

> when i put in 'c 50' it prints but keeps printing the same thing continously not stopping unless i close it. Your switch block: //process what user inputs switch (type) { is inside a `while` loop. Here's the start of the `while` loop: while (type != 'E') So this …

Member Avatar for Erica_2
0
928
Member Avatar for masterinex
Member Avatar for Seandean_1

Edit: Beaten to it by SRL. That'll teach me to type faster :) `Worker_name= worker1,worker2` `Worker_name` is an array of char. In this situation, it devolves to a char pointer. ` worker1,worker2` is basically nonsense in this situation. The `,` operator simply means that first the thing on the left …

Member Avatar for Seandean_1
0
217
Member Avatar for Njay19

The code you have posted compiles fine (except that to use `system`, you should `#include <cstdlib>`). Whatever code you have that produces the error you mentioned is not this code.

Member Avatar for Njay19
0
140
Member Avatar for Kenneth_3

Building it with the following set of warning switches: `-Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion -Wdisabled-optimization -Werror -Wfloat-equal -Wformat=2 -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winline -Winvalid-pch -Wlong-long -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wpointer-arith -Wredundant-decls -Wshadow -Wstack-protector -Wstrict-aliasing=2 -Wswitch-default -Wswitch-enum -Wunreachable-code -Wunused -Wunused-parameter -Wvariadic-macros -Wwrite-strings` gives only …

Member Avatar for Schol-R-LEA
0
249
Member Avatar for Simil

We can't guess what a function does. If we saw the code, we might be able to help you.

Member Avatar for misi
0
227
Member Avatar for Kenneth_3

You've mixed up `printf` and `cout`. cout doesn't do substitution of `%f`. That's a `printf` thing. With `cout` , you just state what you want output with a sequence of `<<` operators: `cout << "y = " << m << " x - " << b << endl;`

Member Avatar for Kenneth_3
0
293
Member Avatar for Dragos_1
Member Avatar for furalise

It's very ugly. #include <iostream> #include <cstdlib> using namespace std; class myclass { public: void class_function() { cout << "Class Function Called" << endl; } }; int main() { void(myclass::*myfunction)() = &myclass::class_function; // make function pointer to the class_function myclass cls; (&cls->*myfunction)(); // when using the function pointer, need to …

Member Avatar for furalise
0
504
Member Avatar for chester1908

What optimisation level are you building the code with? In both those loops, there is a significant amount of work that a good compiler will simply not bother doing. If you build it at the lowest level of optimisation, you might see a different result. What that invites you to …

Member Avatar for chester1908
0
293
Member Avatar for JOHN-shirley

What are you compiling this with? The function binary is expecting an `int*` as the first parameter, but you're passing it an `int`. This is very bad news, and your compiler really should have said something about it. I see also that you're using unknown, basically random values for `a`, …

Member Avatar for Moschops
0
175
Member Avatar for soe win
Member Avatar for Choy_1
Member Avatar for samer.aboufakher.3

Here's the first error: `36:23: error: ‘strncpy’ was not declared in this scope` Now I've helped you find it, you can fix it.

Member Avatar for Moschops
0
202
Member Avatar for VengefulToast

It's more typical to make this operator a friend, rather than a member function. We also need to see the definition.

Member Avatar for Schol-R-LEA
0
494
Member Avatar for Rimi_1

You're missing `;` after you declare functions at the top, you're using a `;` instead of a `,` in line 5 and 6, you're using `;` instead of `:` in some case statements.

Member Avatar for Moschops
0
587
Member Avatar for nitin1

If all you have is a pointer, and it might be pointing to an element of an array, there is NO way to deduce the size of that array. Doesn't matter if it's 2D or 1D. If all you have is a pointer to an element in the array, you …

Member Avatar for Moschops
0
192
Member Avatar for akane.mikazuki

`graphics.h` was a header file released with some compilers back in the eighties and early nineties (i.e. twenty years ago) that enabled a programmer to use a very custom library (also provided wit hthat compiler) to show simple graphics on the systems of the day. Are you programming for MSDOS …

Member Avatar for Schol-R-LEA
0
486
Member Avatar for AQ

Your condition for accepting a number as part of your calculation is wrong. You are accepting it if: `it is a mulitple of three AND it is a multiple of two && it's not a multiple of eight` You've left out the check for having two or three digits, you've …

Member Avatar for AQ
0
137
Member Avatar for James_44

First, the `break` statement on line 97 has no business being there, and the `{` on line 99 has no business being there. Secondly, your loop condition is fundamentally broken. `while (letter != 'Z' || letter != 'z');` The loop will continue as long as `letter != 'Z' || letter …

Member Avatar for Moschops
0
135
Member Avatar for negru

If you look in the call stack, you will see the point at which *your* code calls scanf. The odds of there being a bug in scanf is tiny. The problem is almost certainly in how you are calling it, so when the crash happens, you need to look at …

Member Avatar for Moschops
0
222
Member Avatar for negru

There is no one best. First, turn on lots of extra warnings/errors in GCC, and fix them all. `-Wall`,` -Wextra`, `-pedantic-errors`, and so on. Have a look through the list https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html Then, get the Clang/LLVM C compiler, and rebuild your code with that, similarly with lots of errors and warnings …

Member Avatar for Moschops
0
203
Member Avatar for negru

Delete lines 4, 5, 6, and put this in place: while (n==1) { } Note that your code will loop forever if n is 1. This is almost certainly not what you want.

Member Avatar for Moschops
0
172
Member Avatar for kayleigh0411

You're supposed to be testing the two strings that the user entered, right? So shouldn't you be calling the mystery function AFTER the user has typed those string in?

Member Avatar for rubberman
0
303
Member Avatar for bernardine

You see the `{` on line 16? It marks the beginning of your function `main`. Where is the `}` that marks *the end* of that function? (Hint; nowhere - you need to put it in).

Member Avatar for helmi_1
0
188
Member Avatar for myk45

If you initialise a semaphore value to zero, it means that when you look at it, it will have the value zero. That's it. All the rest is interpretation. If you have decided that you want "zero" to mean "the data this semaphore is referring to is not being used, …

Member Avatar for myk45
0
5K
Member Avatar for jai_5

I expect you're trying to output some kind of character with the value 1. This is an unprintable character and when your terminal gets told to output it, because it has nothing to show, it shows a little box with 0001 in it. You need to check what you're outputting …

Member Avatar for jai_5
0
341

The End.