- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 9
- Posts with Upvotes
- 9
- Upvoting Members
- 7
- Downvotes Received
- 3
- Posts with Downvotes
- 3
- Downvoting Members
- 3
61 Posted Topics
I am writting a simple C++ programm and I want to generate outputs to the console but with the functions 'fwrite' and 'printf'. However, I can't print special characters like 'á', 'é', ... Here is a simple code: printf("Special character: 'ñ'"); Were the output was `±` I found that those … | |
Re: That's because not always all the variables are initiated with a value of 0 or NULL. So you must start your code initiating all the variables of your struct as 0 or NULL, or the value that you want. In your case, when you receive an empty input, it will … | |
Re: I haven't use centos yet, but it seems that it is not the problem. I think that the problem is here: `for(i=0;*email_list[i]>0x0;i++)`. Why are you calling with '*' if you are using '[]'? Try changing that part like this: `for(i=0;email_list[i]>0x0;i++)`. | |
Re: Why don't you use functions to call each node? If you need data that you have aldready use, then why don't you use arrays? Make your code a little bit more readable. | |
Re: Use substr to extract the characters before the word, after that use it again to extract the raw of characters after the word, then join both strings by summing them. Example: string sentence="blah blah blah"; string before=sentence.substr(0,5); string after=sentence(10,14); string withoutTheWord=before+after; | |
Re: First of all, is better to use the standard of main as an int returning function, don't use void. Second, you must read [this](http://www.cplusplus.com/reference/cstdlib/rand/), you are not using well the rand function (it is always showing the same numbers). And third, the way you are multiplying the matrix is ok … | |
I'm using Eclipse and I made a program that reads ID3 tags. The problem is that each time I run it, it stops in this line: TagFrame * tmpFrame=new TagFrame(frameID,header.getFilename(),stream); bufferLeft-=tmpFrame->getFrameSize(); tmpFrame->readObject(); frames.push_back(tmpFrame); //This line!!! Where the variable 'frames' is a std::list<TagFrame*>. This block of code is beeing called from … | |
Re: The problem is here: for(int i = 0; i < HOME_NUMBERS; i++) { for(int j = 0; j < PRICE; j++)//this loop writes the prices outFile << homeInfo[i][j]; outFile << avgCalc(homeInfo);//This line writes the avgCalc after writing the prices outFile << endl; } First, you are writing the avgCalc after … | |
Re: You are not printing any [type](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html) in that way. You need to make a function inside IntegerSet that prints each one of the elements from the set. Method `union(IntegerSet setA, IntegerSet setB)` is returning an IntegerSet class, not an integer or a string. You can implement the [toString()](http://www.javapractices.com/topic/TopicAction.do?Id=55) method if … | |
Re: Adding labels with different background colors to a JFrame is not a good idea (if that's what you did). If you did so, better use [JLayeredPane](http://docs.oracle.com/javase/tutorial/uiswing/components/layeredpane.html) component. You add in it all your components instead of adding them directly to the JFrame. Then you add your labels in a layer … | |
Re: you don't have to read a lot to understand a switch statement. It works like this: switch(variable) { case 1: //do something break; case 2: //do something break; case 3: //do something break; //... default://in case it's an unknown case //do something break; } In your case, `break;`'s are not … | |
Re: You can use a switch to replace an if in some cases like when you ask multiple choice questions. Then the answer will be 'a', 'b' or 'c', specific characters that you can switch. Use variables like `char answer;` or `int amount;` so that you could switch them and operate … | |
Re: When you do this: `readFile >> temp;` or this: `readFile >> temp1;` you are not reading a line, that operator is reading each character until it reaches a whitespace. If there is no whitespace in your file, it will read the whole file. To read a line you have to … | |
Re: I tried your code and it worked fine on my x86 computer. Maybe there is something wrong with the VC compiler or with the visual studio. Is it an "Empty project"? If not you need to add #include "stdafx.h" at the beginning of the file. | |
Re: Try using [EnumWindows](http://msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v=vs.85).aspx) function. It sends you the information from all the current windows. Then you will see if you have a window titled "Windows Task Manager" | |
Re: The visual studio offers you the option to create forms. For using them you need to create a new [windows form project](http://msdn.microsoft.com/en-us/library/ms229601). In this kind of project you can add your .cpp and .h files. It offers you the possibility to create windows like drawing them. You add it the … | |
Re: I found this [website tutorial](http://nehe.gamedev.net/tutorial/playing_avi_files_in_opengl/23001/) in google. It could probably help. There are the codes at the end of the page for all compilers. | |
Re: A node is a simple struct or class that contains elements and a pointer to the next node like K0ns3rv did with `Node * next`. In this case it's better to use a struct because you don't need to make private your variables, it will be harder if you work … | |
Re: Are you making a window application or it's just a console? If it's a console you can use the C function [getch()](http://www.programmingsimplified.com/c/conio.h/getch) from the <conio.h> library. It gets the input character before it's shown. | |
Re: You can't make this work because the thread procedure need to know how many parameters does it have and what kind of parameters. Instead I would try using a va_list ([stdarg.h](http://www.cplusplus.com/reference/clibrary/cstdarg/)), changing the Threading function like this: void Threading(HANDLE &hThread, DWORD &ThreadID, void * FunctionToPass(int,...)) { hThread = CreateThread(NULL, 0, … | |
Re: Don't do it like that. It takes too much time and wastes to much memory. Instead of creating an array with every number, try switching the random number generated: [CODE]switch(generatedNumber){ case 1: total1++;//increment the total of number 1 case 2: ... }[/CODE] There are other ways to get the same … | |
Re: Try searching those errors in google. [URL="http://msdn.microsoft.com/es-es/library/ewcf0002(v=vs.80).aspx"]http://msdn.microsoft.com/es-es/library/ewcf0002(v=vs.80).aspx[/URL] You need the "std" namespace for string and vector. You can either add a line with "using namespace std" or replace "vector" by "std::vector" and so on for each string. | |
Re: What's class "student"? You have to add constructor in the class Teacher to construct this class with a Student. In main you can't call class Teacher if you write "teacher"(with a lower case letter). It must be like this: [CODE]/*upper case only for the first one wich is the class*/Teacher … | |
Re: Why don't you try it yourself? As the name of itself says "Global variables", you can only create variables, as many as your computer can. | |
Re: I can help you with two errors. FIRST [QUOTE]main.c:11: error: syntax error before '%' token[/QUOTE] When you use fscanf the format must be as a string of characters: between quotes. [CODE]while(y = fscanf(p, %c, &(item.key))!EOF);[/CODE] SECOND [QUOTE]printlist.c:11: error: request for member `data' in something not a structure or union[/QUOTE] If … | |
Re: [QUOTE][CODE]cout<<i<<". "<<m_pBuffer[i]<<endl;//m_pBuffer[i] is a CComplex[/CODE][/QUOTE] CComplex is a class and you can't print it in this case. Maybe you could try printing a value contained in that class. | |
Re: There is a class [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/label.html"]JLabel[/URL] that you can use to add text. You can hide a JLabel containing the text "YOU WIN" (setVisible(false)) and when the bounds of the image intersect to ones of the cheese, then you can make it visible again (setVisible(true)). | |
Re: I can't understand exactly what you are trying to do. item1 and item2 are Integer types or classes. You are using templates. That's why it gives you that error. If you are trying to remove element x from a list you have to do it like this: [CODE]list.remove(x);//where x is … | |
Re: can you show us an example where your code doesn't work as you thinked? I didn't see any error in this segment of code. | |
Re: The program isn't skipping any values. ashlock is right, the character '\n' (Enter) is taken as a character in the input of the program. If you still want to use the functions 'scanf' and 'printf' you will have to use a "fflush(stdout)" after calling the funtion printf and a "fflush(stdin)" … | |
Re: You need first to read an integer, not a string. You have to use:[CODE]fscanf("%d\n",&i);[/CODE] Then you will need to create an array of characters (string) with the size readed using a pointer([URL="http://www.ics.uci.edu/~dan/class/165/notes/memory.html"]malloc[/URL]). After that you will have to use a 'while' loop: [CODE]while(i>0){ //read character i--; }[/CODE] or if you … | |
hello i'm trying to draw a kind of arrow with an specific thickness. i've already this: [CODE] public void paintComponent(Graphics g){ super.paintIcon(comp, g, width, height); for(int i=0;i<thickness;i++){ Polygon arrow=new Polygon(); arrow.addPoint(7*scale, 0*scale+i); arrow.addPoint(14*scale-i, 9*scale-i); arrow.addPoint(10*scale-i, 9*scale-i); arrow.addPoint(10*scale-i, 29*scale-i); arrow.addPoint(4*scale+i, 29*scale-i); arrow.addPoint(4*scale+i, 9*scale-i); arrow.addPoint(0*scale+i, 9*scale-i); g.drawPolygon(arrow); } g.setColor(Color.BLUE); Polygon arrow=new Polygon(); … ![]() | |
how can I sleep my program without sleeping others (or making them slower)? I am using a windows application. here is a fragment of my code: [CODE] //#includes... int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, char * cmdParam, int cmdShow) { MSG msg; int status; Window myWind(SW_SHOW,"Name",150,120,500,0); for(int i=0;i<550;i++){ myWind.setLocation(i,i); … | |
Re: you can't do this unless your app has a function to run java. then you could try getting a java function for your own program. I recommend you to don't do that because the iphone doesn't support Java. it would run very slow. | |
![]() | Re: use: [CODE]double x=0.555; System.out.println(Math.round(x));[/CODE] to round a double easily. |
Re: you forgot the ';' in: [CODE] ... //HERE - > calc == "calc;" if(calc == "calc") { system("calc"); } else { ... [/CODE] and also you have to include the <stdlib.h> header. without it you can't use "system" | |
Re: is "Rectangle" a JPanel? I don't think in this section of the code is the error. | |
Re: you can use the C method [URL="http://www.cplusplus.com/reference/clibrary/cstdio/scanf/"]scanf[/URL]. so you can read a number followed by a character followed by another number. You can´t read an operator, it would be like reading a function, impossible. | |
Re: check this: [URL="http://www.devdaily.com/blog/post/java/remove-non-alphanumeric-characters-java-string"]http://www.devdaily.com/blog/post/java/remove-non-alphanumeric-characters-java-string[/URL] | |
Re: That's because your code is wrong. rand() function always include 0: [CODE]int value = rand() % (range + 1);[/CODE] | |
Re: you have to use a do-while or while loop in this case. You could try: [CODE]while(true){ cout... cin... switch() { case ... default: cout<<endl<<"Incorrect";continue; } break; }[/CODE] | |
Re: Here is a tutorial of mysql: [URL="http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-tutorials.html"]http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-tutorials.html[/URL] | |
Re: In this website we won't solve all your problems by pasting a piece of code. If you have problems with your arrays you could try to use an ArrayList instead of simple arrays. An ArrayList is a linked list (kind of array) which is used to add elements and remove … | |
Re: In option A you have to initiate your var 'c' like this: [CODE]char * c=new char[length];[/CODE] That's why it gives you an error. It's a [URL="http://www.cplusplus.com/doc/tutorial/dynamic/"]pointer[/URL]. | |
Re: your code isn't wrong but the size of the array is too big. Your are creating a 100*100*100 sized array. if you try with a slower array it will work. | |
Re: you don't use the for loop like that. the condition must be f<20. it works like a while. The while is the opposite of an if. That's why you're getting zeros, your int array has never been initialized. | |
Re: have you tried to use [CODE] ImageIcon bug1=new ImageIcon("20072011001.jpeg"); ImageIcon bug2=new ImageIcon("20072011002.jpeg");[/CODE] ? | |
Re: java can't read Javascripts. The code that is showing you the program is a javascript. | |
Re: you could use toupper() but also you could try an if statement: [CODE]if(ch is between 'a' and 'z') ch+=('A'-'a');[/CODE] | |
The End.