chrjs 42 Junior Poster in Training

You could try making the main function a friend of the DisplayController class, although that is more of a work-around than an actually solution.

chrjs 42 Junior Poster in Training

Are the ALLEGRO_BITMAP, ALLEGRO_EVENT, ALLEGRO_EVENT_QUEUE identifiers macros, or just normal types?

chrjs 42 Junior Poster in Training

What API are you using?

chrjs 42 Junior Poster in Training

Although Ancient Dragon's solution should work, the problem with your original code is probably with the byte order. Most modern computers have little endian byte orders meaning that the bytes are stored least significant to most significant, e.g. a 16-bit integer of 0x1234 would be stored as the 8-bit bytes 0x34,0x12. You read the bytes with a big endian byte order, which is most significant to least significant. Basically, you need to flip the subscripts on line 9.

chrjs 42 Junior Poster in Training

You never include <string> or <iostream> in your header file so the "string" class is undeclared (you should put "using namespace std;" in your header too). Also you are using names for your get, set, and variable declarations for your strings.

chrjs 42 Junior Poster in Training

You need to somehow determine what the input file is like through arguments or cin, and then write a loop around the calculations that reads the data from the file until the sentinel value is reached.

It looks to me like you just posted the code from that assignment #3 of yours and didn't even try at this one.

chrjs 42 Junior Poster in Training

If your writing a program for windows XP, not DOS, then your target executable should really be a .EXE not a .COM

chrjs 42 Junior Poster in Training

Arrays work the same in 16-bit and 32-bit, you just have to allocate enough memory on the stack that you need.

; allocate space for an array of 10 bytes

sub sp, 10
mov bx, sp

; bx is the pointer to the start of the array
chrjs 42 Junior Poster in Training

In 32-bit protected mode, interrupts are used as exception handlers, like what Athelas said. They are essentially handled exclusively by the operating system and the hardware. And in 32-bit pmode, you can't call an interrupt from your program (unless your program is the kernel or a driver.)

In 16-bit real mode, interrupts can be called by any program and in older operating systems (like DOS) they were used when a program wanted to communicate with the kernel. For example, int 21h was often used for I/O in DOS.

chrjs 42 Junior Poster in Training

It's a gross generalization, but in my experience, if the publisher is out of India, it raises red flags; I have yet to see a decent beginner's book on programming come out of India. Can you learn from these books? Absolutely. Will you pick up an excessive number of bad habits along the way? Very likely.

Go here and find a book that's either recommended or highly recommended.

Isn't that like kind of general? Thats a huge list of books, and it seems to me like the majority of them are C++ oriented, not C oriented. In my opinion, "The C Programming Language" by Brain Kernighan and Dennis Ritchie is probably one of the best books on ANSI C.

chrjs 42 Junior Poster in Training

Where is strdup() defined? How is it defined? It's not an ANSI function.

strdup is part of the GNU C library which can be found basically every linux machine. It is a declared inside of string.h. It duplicates a string like strcpy, but uses malloc so it can be freed later.

chrjs 42 Junior Poster in Training

Quick question do you know the relevance of the keyword extern ?

I removed extern and the program compiled with just 1 warning

The extern keyword means that the variable is defined outside of that source file. The warning you got probably came from using the variables that were declared as extern without defining any value for them.

chrjs 42 Junior Poster in Training

That is platform-dependent, what OS do you have? The easiest solution would probably just be to use the system() function with a console command that would do that for you, like "find" on *nix systems.

chrjs 42 Junior Poster in Training

If you don't have a question, then this should go under code snippets. Also, it would be best to stay away from non-portable deprecated libraries such as graphics.h and conio.h

chrjs 42 Junior Poster in Training

In string constants enclosed in quotes, the backslash\ is used as an escape sequence so you can put in characters that you normally couldn't type into the string, like \" or \' so you have to use the escape sequence for the \ in the file name which is just \\

chrjs 42 Junior Poster in Training

You could also take out the prototypes for those constructors.

Ancient Dragon commented: good point :) +36
chrjs 42 Junior Poster in Training

You never allocate any space for the char pointer arg[1] . You could either call a function like malloc and dynamicly allocate space for that c-string, or you could declare the c-string to the stack, like char arg1[100]; .

chrjs 42 Junior Poster in Training

yah..=D that works for me..
and a other question.. if my system is 32bit, i coulnt use 64bit registers?

Then just replace "%%rax" with "%%eax" and "movq" with "movl"

wildplace commented: :D thx +2
chrjs 42 Junior Poster in Training

In your for loop in the traverse function you have the condition list.next()<=list.length() , but list.next returns a bool value, meaning that it is either 1 or 0. And since the length never changes inside that loop, that loop is infinite unless you enter the loop with the list having a length of 0.

Use code tags, and its Josep[B]h[/B]us, not josepus
chrjs 42 Junior Poster in Training

Like WaltP said, you should have the command write to a file and then read from that file. You should probably use the "system" function in stdlib.h. You don't have to "embed" a shell inside of your C program. Also, the good thing about the find command is it lists all the files it finds line by line, so you only need to use a function like "fgets" to read the filenames from the file generated from find's output.

chrjs 42 Junior Poster in Training

In your scanf statements, you are dereferencing a pointer and then referencing that, which basically does nothing. You pass pointers into getDate, so you don't need to dereference of reference anything, you can just write it like

scanf("%c", vehic);
chrjs 42 Junior Poster in Training

It probably doesn't have to do with the source code. I think it is because that the compiler/IDE you are using doesn't have write permissions for your target. Try running your compiler/IDE in administrator mode and then building the project again. If that doesn't work, you could try deleting the target executable from a previous build.

chrjs 42 Junior Poster in Training

You also should be able to replace the "600" in Unseen Machine's example with a call to dbScreenHeight() for readability and so that you don't have to change that in the case that the screen size changes, but you still should adjust that value to the rocket's size by subtracting the size of the rocket from that value.

chrjs 42 Junior Poster in Training

I would recommend that you use an std::string instead of a char*. std::strings are safer than char*s and don't require functions like strcpy. So for example:

std::string highest_str;
//you don't need the "std::" if you have "using namespace std;" in your code

//...some code here...

highest_str = "January";

//...some code here...
WaltP commented: Doesn't requite changing types. Char* works just fine. -3
chrjs 42 Junior Poster in Training

Wrong forum, this should be in Hardware & Software->Microsoft Windows->Windows Vista and Windows 7.

chrjs 42 Junior Poster in Training

Post the code you have and ask a more specific question, no-one is going to bother to do this for you.

chrjs 42 Junior Poster in Training

cin>> number;
int count[number]={0};

The problem with this is that when you declare an array it must be of a constant size. You would have to declare count as an int pointer and dynamically allocate memory.

int size;
cin >> size;
int *count = new int[size];
chrjs 42 Junior Poster in Training

In your while statement on line 35 you are using a %s to get input for a float, I don't know what result this will produce from fscanf, but it is possible that the loop is never entered and that the calday is never called, and even if it is you probably would receive weird results anyway. You should probably use a %f instead of a %s.

chrjs 42 Junior Poster in Training

It's not a scripting language, its a markup language. A scripting language can be used to communicate instructions to the machine or a program, while a markup language is only used to format information.

chrjs 42 Junior Poster in Training

The struct that starts at line 17 is never closed or named, also the union that that struct is in is never named. But I think it is kind of useless to have a union that only has 1 element in it anyway, I would recommend removing that union.

chrjs 42 Junior Poster in Training

Yeah, you have to allocate space for the strings using a function like malloc() or calloc(). Or you could also just declare your strings like char input[100] or something like that. Also, you should use // or /* and */ to indicate your comments.

chrjs 42 Junior Poster in Training

the std::getline function puts its output into a std::string, the std::ifstream::getline function puts its output into a char*. You should call getline like fp.getline(buffer, SIZE);

chrjs 42 Junior Poster in Training

Show us at least what you have attempted so far.

chrjs 42 Junior Poster in Training

HTML is not a high-level language, it is a markup language. Basically, all it does is tell a program, like a web browser, how to display information on the screen, for example, like how this text is green.

You can't ask the question "Why would you want to compile html" because you simply can't compile html. You can't run an html file in a command line, nor can it be compiled to run in the command line. It is impossible.

chrjs 42 Junior Poster in Training

I would pass quarters, cents, dimes, nickels, and pennies into calcPay as a refrence, like float calcPay(float& quarters, float& cents, float& dimes, float& nickels, float& pennies); , then you should be able to modify them correctly in calcPay.

chrjs 42 Junior Poster in Training

Your calcPay function is never prototyped, so you can't call it from main (you do have a prototype for calcchange(), a function that is never declared, though).

Also, you never use the h and r parameters passed into calcPay. This isn't a syntax error, but it is probably not what you want to do.

And last of all, the values quarters, cents, dimes, nickels, and pennies, are not initialized inside off calcPay (or anywhere for that matter). And fpay in main is also not initialized or declared.

chrjs 42 Junior Poster in Training

Can we see the declarations of you time12 and time24 classes?

chrjs 42 Junior Poster in Training

Yes, I would load the file into a buffer and search the buffer for the string. When searching for the string, I would loop through each character of the buffer and compare each character to the first character of the string you are looking for. Whenever you find the first character, just check to see if the rest of the string is there.

chrjs 42 Junior Poster in Training

Its because when gcc compiles the code, it first evaluates the equations then pushes the registers for the function call. In the first example with the local variable it evaluates the expressions a=10,a=20, and a=30 into the same location in the stack, then it pushes that location in the stack 3 times. In the second example with the global variable, it evaluates into the global variable and then moves the global's value into separate registers. After the evaluation, it then pushes the individual registers into the stack for the printf call.

You can compile the progams with the -S flag and look at the .s (assembler) files to see exactly how it works.

chrjs 42 Junior Poster in Training

I don't know much about SFML, but if you are changing the center (I am guessing thats the same thing as an origin), it is essentially changing location of where the square is draw relative to it's position. You should try repositioning the square relative to the new center.

chrjs 42 Junior Poster in Training

Although if you don't want to use vectors, the problem probably is that at line 26, you are changing the value of the local variable p in the function increaseArraySize, which doesn't change the value of the p in addEntry. You should pass p as a reference like void increaseArraySize(phoneBook *& p, int &numLines, int a)

chrjs 42 Junior Poster in Training

Normally, you would prototype all the functions that you want to use in one .c file that are defined in another in a header (.h) file, then use the #include statement to include that header, and then indicate to the linker that you are going to use both .c files.

You could also just #include the .c file in the other, but this is considered bad practice.

chrjs 42 Junior Poster in Training

html is also not object oriented, but I think what you are asking (correct me if i am wrong) is if different methods of interpreting html performed by different web browsers will change the actual results displayed on the screen, and the short answer is no, except in the situation where you are using an extremely poorly coded web browser.

chrjs 42 Junior Poster in Training

HTML is not a compilable language (at least in the traditional sense), so therefore, this question makes no sense. Also, I don't see what this has to do with Linux/Unix

chrjs 42 Junior Poster in Training
#include<stdio.h>


int main()
{

  int i,j,temp;
  
  printf("\nEnter the Number :");
  scanf("%d",&temp);


  switch(temp)
{
  case 1:
           for(i=0;i<5;i++)
           {
            
              for(j=0;j<=i;j++)
              {
                 printf("*");
              }
              printf("\n");
           }
           break;

  case 2:

           for(i=5;i>0;i--)
           {
            
              for(j=0;j<=i;j++)
              {
                 printf("*");
              }
              printf("\n");
           }
           break;

  case 3:
           for(i=5;i>0;i--)
           {
            
              for(j=0;j<=i;j++)
              {
                 printf("*");
              }
              printf("\n");
           }

           break;

  case 4:
           for(i=0;i<5;i++)
           {
            
              for(j=0;j<=i;j++)
              {
                 printf("*");
              }
              printf("\n");
           }
          break;


       default:
            /* Do nothing*/
}


  return 0;
}

Adak is absolutely correct.. But what I don't understand is, if you did the code for (1) and (2), (3) and (4) is copy pasting stuff. Anyways here is the code, hope this helps :)

You didn't read the entirety of his post, he wanted the triangles like.

(1)
*
**
***
****
*****

(2)
*****
****
***
**
*

(3)
*****
 ****
  ***
   **
    *
    
(4)
    *
   **
  ***
 ****
*****
chrjs 42 Junior Poster in Training

What I would recommend doing is changing the array order from an array of menuItemType to an array of integers that has an element for every item on the menu increment the array by 1 in the appropriate element of the array every time someone orders something.

That way for an order of 1 "plain egg" and 2 "bacon and egg" your array would look like 1,2,0,0...

chrjs 42 Junior Poster in Training

By KBC, do you mean the Keweenaw Brewing Company or the Kentucky Baptist Convention?

jonsca commented: Nice +7
chrjs 42 Junior Poster in Training

I noticed that you are using the non-standard library conio.h in your code, its a pretty outdated library and it would probably be better to use a different library, but it does provide support for input that doesn't echo to the screen with the getch() function (which you actually use in your code).

If you want to use conio.h, then something like this should work

string getPassword()
{
	string s = "";
	char c;
	while ( (c = getch()) != '\n' )
	{
		cout << '*';
		s += c;
	}
	
	return s;
}
chrjs 42 Junior Poster in Training

When the function is called from main x has a value of 7, and the function calls itself with a value of x - 1 until x equals 0. So therefore, the function is called 7 times with x = 1 - 7 and outputs the * based on the value of x.

chrjs 42 Junior Poster in Training

I think you mean:

#include <iostream>
#include <fstream>
 
using std::cin;
using std::cout;
using std::iostream;
using std::ifstream;
 
int main()
{
 
   // your program goes here
 
}