Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

warning C4244:

You are getting that because the program is assigning a double to an int -- for example assigning a double value to Mercury. That's not really a problem unless you expect Mercury to have fractions. The way to remove such warnings is to convert the result of the weight calculations into int before assigning to int variable, that's called typecastging. For example: Mercury = (int)(EarthWeight * 0.37);

The error on line 46: You have confused the syntax between printf() and cout. If you want to use printf() then don't use <<.

printf ("You're weight would be %d\n", Venus);

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My question is, can I change them into a single variable EACH?

Yes, declare three strings, assign some value to them, then compare if the if statement

Test the program I posted to see if it works for you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I actually want the syntax to store it in file after comparison

There isn't much to it -- just one line of code which you can easily get if you take the time to read a textbook or an online tutorial. I'm not going to tell you what it is because you need to learn how to look up the answers to your questions yourself before just asking others to do it for you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You need to open both files before doing anything and keep them open until the program is done comparing numbers. Opening files is very time consuming, so just open once during the lifetime of the program.

open file1
open file2
start of loop and repeat 10 times
   get input
   if value < 0 
      save in file1
    else if value > 0
      save in file2
end of loop
close both files
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

that isn't c++, it's assembly

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There is no difference as far as efficiency, references are actually implemented as pointers. The difference is in safety because references can not be changed once set.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Use two loops, one nested inside the other. The outermost loop counts rows (1-5) and the inner loop counts from 0 to the value of the outer loop.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't. The computer that is running the vb program must also have the Access odbc device driver and the Access database file. If you mean you want to call Access from your vb program then read one or more of these tutorials

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Read the tutorials I posted. You will have to spend a few days or weeks wading through all that information. It isn't the easiest things to understand. You need basic knowledge of C programming language in order to comprehend it all.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

But HOW?

I have no idea -- ask your teacher how to drive the priority list from the matrix.

main()

Learn to program correctly -- it's int main(), not just main(). There is int before the function name.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

So,the coding will be compare all integers with 0 and save according in two different files right?

Correct.

If I am right then how to store it in files?

See FILE* file handling functions (a tutorial is here).

Can we save it in already existed file?

Yes, see the above turorial how to do that. It's one of the flags given to fopen() function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
  1. PC, mem_CARD, soft_WARE, and disk_DRIVE should be an int, not double because you can't by a fraction of those items, whole numbers only. Use the data type that is appropriate for the thing you want it to represent.

mem_CARD + MEMORY_CARD

You need to multiply those numbers, not add them. * multiplies

I also dont understand why the code text is not showing up in the different colors that its supposed

Each editor has its own way to color-code c++ text, don't expect all editors to look like Turbo C

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I thought that solved the problem, but it doesn't Ctrl+0 (zero key. the one above the letter 'P') makes the font smaller but hides the purple bar.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I posted sudo code that accomplishes that. And DavidB posted a complete program. What more do you want? Maybe you just don't understand what we posted. Put David's program into your compiler's editor, compile it, then run it to find out for yourself what it does. Then compare the program you posted with David's.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Correct solution but you shouldn't do people's homework for them, no matter how tempting it is.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why use an array? Just sum the numbers as they are entered then print the result when finished, no need to keep them.

start of loop
   enter a number
   if number less than 0?  if yes then exit the loop
   sum = sum + value of number entered
end of loop
print value of sum
NathanOliver commented: Thanks. I over thought that +10
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You want to call the win32 api funcgtion GetOpenFileName(), here's an example program. You can call it from a standard console program that uses main() if you wish instead of from a win32 program that uses WinMain()

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think a lot of people are interested in updates!

Name one.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your program could be improved by better use of if statements and using only two FILE*pointers.

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>


int main()
{
      int opt,opt1,a;
      int x, index;
      char fn[15],ln[15],sn[15],data[15],line[225];
      char locate[15];
      FILE *fp1, *fp2;
      char* filename;

      printf("\t\t\t\t*****MENU*****");
      printf("\n\n\n");
      printf("\t\t\t\t***STUDENT PROFILE***\n\n");

      fp1=fopen("2003.txt","r");
      printf("2003 Student Enrollies\n\n");
      printf("Student Number \t\tFirst Name \t\tLast Name\n\n");

      printf("\n\nEnter Data to Display: ");
      scanf("%s",&data);
      while( fscanf(fp1,"%s\t%s\t%s\n",&sn,&fn,&ln) > 0)
      {
            printf("\n%s\t\t\t%s\t\t\t%s",sn,fn,ln);
            system("cls");
            index = 0;
           if((strcmpi(data,"1234")==0)||(strcmpi(data,"John")==0)||(strcmpi(data,"Doend")==0))
               filename = "03/1234.txt";
           else if((strcmpi(data,"3214")==0)||(strcmpi(data,"Jane")==0)||(strcmpi(data,"Dredy")==0))
               filename = "03/3214.txt";
           else if((strcmpi(data,"2104")==0)||(strcmpi(data,"Joey")==0)||(strcmpi(data,"Drone")==0))
               filename = "03/2104.txt";

           fp2=fopen(filename,"r");
           while(fgets(line, sizeof(line), fp2) != NULL)
           { 
                 printf("%s",line);
           }
           fclose(fp2);
      }
      fclose(fp1);
      printf("\n\n");
      system("pause");

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

win32 api has no function that reads one line at a time such as fgets() and getline() do, instead they do binary reads similar to fread() and fstream.read(). If you want to read a file in text mode then don't use win32 api functions but standard C or C++ file i/o functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I wonder how it got re-opened? Looks like closing threads doesn't work.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are using Turbo C then you can call assembly int 10H, set up the registers with screen coordinates then call int 10H. I used that often in MS-DOS 6.X but don't know if it still works in MS-Windows console screeen.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

\n is an escape character that moves the cursor to a new line
\b is backspace
\r moves the cursor back to the beginning of the current line

So if you use pencil & paper to draw the characters on paper and follow the above escape characters you will see how the result is hai.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

is there any way i can limit the decimal places?

setprecision() should do it.

i want to put an boxed outline around the the result of the calculation how would that be done?

print the extended ascii codes, see this chart. That assumes you are using standard English ascii char set that is installed with MS-Windows os.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try cout << fixed << totalwin

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No you aren't because there was no such thing. Go to the About Box and check the version number.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Which version of vc++ Express did you install? Earlier versions did not contain windows.h or related headers/libraries, you had to also download windows SDK. Microsoft includes all that with version 2008 (I think that was the version). If you have the older version then uninstall it and download the latest version (free) vc++ 2010 Express. It won't be available much longer because they will be releasing vc++ 2012 soon.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

take it from where?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are printing the results to the screen, post the code that prints it. It might be just a display problem instead of a problem with the data.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use fgets() to read an entire line at one time. But since you are using c++ you really need to learn the <fstream> and <string> library fuctions.

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
FILE *fp1;
char line[255];
fp1=fopen("data1.txt","r");
while(fgets(line, sizeof(line), fp1) != NULL)
{ 
     printf("%s ",line);
}
fclose(fp1);
printf("\n\n");
system("pause");
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That works! thanks.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

did you try googling for it?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It should be a simple program if all you want to do is enter the data from the keyboard and store the info in a text file. Just declare a few data items for each of the things you want in the text file, print a prompt for each, and use scanf() or fgets() to enter the data. After that either save in an array for later or use FILE* to save the info to the text file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what version of vc++, there are several of them (its a compiler, not a language). Did you google for treeview tutorials?. You might also want to search codeproject.com because they have hundreds/thousands of free MFC tutorials and example programs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

list view? What language -- MFC, QT, or are we supposed to guess?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Everyone makes mistakes, it's a fact of humanity.

I only made one mistake in my life, that was when I thought I was wrong, but I was wrong about that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What compiler are you using? Learn to use your compiler's debugger so that you can step through the program and find out for yourself what is causing the problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is C# way to do it, which is almost identical to CLR/C++ (which you are writing).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't need arrays or while loops. Just use three simple for loops. The first counts the number of rows, which is 6. The second displays space(s) to move the cursor on the screen, and the third displays the letters in reverse order that they appear in the alphabet.

loop counts from 0 to 6 // you need 6 rows of data on the screen
   loop counts from 0 until it reaches the value of first counter
      display a space
   loop counts from 'F' - value of first counter, down until it reaches 'A'
       display char value of the counter
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just briefly looking at your program, on line 34, what's the value of m? Answer: undetermined because you failed to set its value to something (using an uninitialized variable).

Next problem is that arrays have valid indexes as 0, 1, 2, 3, ... N-1. Your loops should start at 0, not at 1, and continue until < N, not <= N.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What language is the software written in? There are hundreds of them. What you should do next depends on the language. Some languages such as html and java are interpreted when they are run, others such as c, c++, c#, and VB require a compiler to translate the text file that contains the program into an executable program. And there is a different compiler for each language that reauires a compiler.

As for books -- search amazon.com. Usefule websites: how about DaniWeb???? w3schools is another good one for web programming.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I assume you are using *nix os, so if you get a core dump then run gdb or another debugger that will tell you where the problem is assuming you compile your program for debug.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

nitin1 is correct, the question is not c or c++ related, but how to use a modem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The smallest unit of storage in a computer is one byte. What you want to do is to bitmap the byte(s) of memory, one byte normally holds 8 bits (but may vary depending on the operating system). So if you want an 8x8 matrix of bit then use an array of 8 unsigned char, e.g. unsigned char bits[8], then you can use shift operator and/or the & and | operators to set/clear specific bits.

Another way to do it is to define a structure that contains the bits

struct bits
{
   unsigned char b1:1; // bit 0
   unsigned char b2:2; // bit 1
   // etc for 8 bits
 }

 struct bits bitArray[8];

With the above structure you can set/clear bits by using the bit name instead of shifting. Example: bitArray[0].b1 = 1; // set bit 0

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I compiled your program with vc ++ 2012 and, after changing a couple things to make it compatible with new compilers, it worked as expected for me. I don't have Turbo C so I can't tell you if its your compiler or not that is causing the problem. Or maybe you just misunderstand how the program is supposed to work correctly.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you trying to run MinGW under a linux emulator? You probably don't have permissions to run MinGW from within c:/users/mat folder. Move MinGW to C:/MinGW then make sure to grant access to everyone then try again.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

maybe the pictures are too large??

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem you see is that c++ stream library may or may not be thread safe meaning that you might see almost any random output or a mixture of the two. Read this thread for more information.

If you want specific output then you will have to add thread synchronization techniques, such as creating and using a mutex. Here are a few google links you might want to read.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I've never seen Dirent.h or any of those includes before.

You will see them a lot when you do *nix programming. Just like you see windows.h when doing Ms-Windows programming. C is the standard implementation of os interface functions because almost all other languages can call them. c++ functions can only be called by c++.