WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Oh come on, really. What should you use to output a statement? You can't be that new. Didn't you do a Hello World program?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi!

Hi

I want to read a dbf file in c/c++/vc++. Which platform would be ideal?

Any platform will do it.

And how should I go about it?

Regards,
Nidhi

Understand the database file format. That's most of the battle -- and in the case of .dbf, it's more of a skirmish.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Which one is the inner loop? Which one is the outer loop?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I saw him a couple times live. I hear when his brother took over the show it wasn't quite as good although I never saw him.

Trivia question: What is Gallagher's first name?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

That completely depends on why he called the function twice. Not enough information for a solid guess.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Nest loops by putting one inside the other:

while (xxx)
{
    for (x;y;z)
    {
        do
        {
        } while (aaa);

    }
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You have to look into how to convert a float into a string first. Check your book.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Convert it to a string, remove trailing 0's, the output the string.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi
malloc is the best practice to do programmings like Fibonacci

Why?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sounds like it worked... welcome.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Either make choice a single character and acquire it by cin.get(choice); (you will need a cin.ignore() after to mop up the '\n'
or use if(strcmp(choice,"Y") ==0) instead of your (choice == "Y") EDIT: D'OH WaltP beat me to it

Or if(choice == 'Y') with choice as a single character.

Wonder why we always have to edit a post to acknowledge being beaten... :-/

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I've searched up fgets() , and on most of the websites I read that this is an un-save function which can return faulty values.

What nezachem said...

Also getline() is a member of iostream, which I planned "not" to use because of the weird syntax.

What's weird about it?

There aren't any other ways to do this? It's just weird for me since I always worked with language which where type-safe.

Yeah, but the syntax is even weirder -- and harder...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You can't. That's why I asked about kbhit() . With that function (or one similar -- google) it can be done. That is as long as getch() is identical to Borland and Microsoft. I heard it wasn't at one point.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You seem to have misinterpreted my question. I was not assuming you just blew in here for us to write your code for you -- although that does happen far too often. I meant:

"Currently I overflow 'float top' at an x value greater than 13."

I wanted a better explanation of what this meant so I know for sure.

What were you expecting as an answer?

What did you get for output and what did you want for output? I can't see your screen so you must give us the details.

My guess is you are overflowing the precision capabilities of the float type.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

cout<<"Would you like to preview your output file? (Y/N)"<<endl;
This is the line I am talking about, sorry for misquoting.
But yea I tried inputing 'Y', I will try 'y' but I dont know it it will work

Wait a minute....

You've defined char choice[2]; you're inputting cin>>choice; So what is in choice at this point? Both bytes?
And is if (choice == "Y") the proper comparison -- with Y as a string?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

All I know is if governments were people, every one of them would be committed to asylums. And not one seems to have any fiscal sense, nor responsibility.

With a "government of the people, by the people, for the people", how is it the people keep getting screwed?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

By not using scanf() . You need to read the entire input as a string and validate each character. If it validates properly, convert the input to an integer.

Look at fgets() Actually, using C++ you want getline()

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I am only allowed to use int, unsigned int and float. Must be accurate to the 7th significant digit. Currently I overflow 'float top' at an x value greater than 13. Thank you for your time.

Meaning?
What were you expecting as an answer?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

hey everyone, I got a weird error when I run my program. I compile and link and run the program through the terminal in Ubuntu. I have to compile or linking errors, and the program run's fine, except when the program asks:

"Would you like to see a display of the output (Y/N):"

I don't see this message anywhere in the code...

Regardless, the only response that seems to work will be Y. y will not work.

cout<<"Would you like to preview your output file? (Y/N)"<<endl;
cin>>choice;
if (choice == "Y")  // only an upper case Y can be entered
{
  cout<<"Generating preview of output....."<<endl<<endl;
}//end if
else
{ cout<<"Very well...MOVING TO NEXT PROCESS"<<endl;}
};//end print_to_screen
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Does Dev-cpp have the functions kbhit() and getch() ? If so, look up what they do. If not, I don't know if Dev can handle it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Too bad. What are you going to do about it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Your class Gradebook has a private value named courseName. The only way to put a value in it is to call setCourseName( name ) to load the value name into it.

And since it's a private value you must call getCourseName() to retrieve it.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

HAH,why would you even give him a response. PLLLLSSSSSSSSSSSS

Someone might ask that same question of you... :icon_rolleyes:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

It also depends on the compiler you are using. Only a few compilers can really do what you want.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

This might get you started:

#include <iostream>
#include <cstdlib>
using namespace std;
char diseaseDNNAsignature[] = 
                  { 0x41, 0x67, 0x65, 0x6E, 0x74, 0x3A, 0x20, 0x48, 
                    0x69, 0x20, 0x46, 0x61, 0x72, 0x6D, 0x65, 0x72, 
                    0x20, 0x46, 0x72, 0x65, 0x64, 0x2C, 0x20, 0x46, 
                    0x61, 0x72, 0x6D, 0x65, 0x72, 0x20, 0x4A, 0x69, 
                    0x6D, 0x2E, 0x0D, 0x0A, 0x46, 0x72, 0x65, 0x64, 
                    0x20, 0x26, 0x20, 0x4A, 0x69, 0x6D, 0x3A, 0x20, 
                    0x48, 0x69, 0x2E, 0x0D, 0x0A, 0x41, 0x67, 0x65, 
                    0x6E, 0x74, 0x3A, 0x20, 0x44, 0x69, 0x64, 0x20, 
                    0x79, 0x6F, 0x75, 0x20, 0x6B, 0x6E, 0x6F, 0x77, 
                    0x20, 0x79, 0x6F, 0x75, 0x72, 0x20, 0x73, 0x68, 
                    0x65, 0x65, 0x70, 0x20, 0x61, 0x72, 0x65, 0x20, 
                    0x64, 0x69, 0x73, 0x65, 0x61, 0x73, 0x65, 0x64, 
                    0x3F, 0x0D, 0x0A, 0x46, 0x72, 0x65, 0x64, 0x3A, 
                    0x20, 0x4E, 0x6F, 0x2C, 0x20, 0x68, 0x6F, 0x77, 
                    0x20, 0x63, 0x61, 0x6E, 0x20, 0x79, 0x6F, 0x75, 
                    0x20, 0x74, 0x65, 0x6C, 0x6C, 0x2E, 0x0D, 0x0A, 
                    0x41, 0x67, 0x65, 0x6E, 0x74, 0x3A, 0x20, 0x53, 
                    0x65, 0x65, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 
                    0x66, 0x6F, 0x61, 0x6D, 0x20, 0x61, 0x72, 0x6F, 
                    0x75, 0x6E, 0x64, 0x20, 0x74, 0x68, 0x65, 0x69, 
                    0x72, 0x20, 0x6D, 0x6F, 0x75, 0x74, 0x68, 0x3F, 
                    0x0D, 0x0A, 0x4A, 0x69, 0x6D, 0x3A, 0x20, 0x59, 
                    0x65, 0x61, 0x68, 0x2E, 0x20, 0x20, 0x57, 0x68, 
                    0x61, 0x74, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x77, 
                    0x65, 0x20, 0x64, 0x6F, 0x3F, 0x0D, 0x0A, 0x41, 
                    0x67, 0x65, 0x6E, 0x74, 0x3A, 0x20, 0x57, 0x69, 
                    0x70, 0x65, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 
                    0x66, 0x72, 0x6F, 0x6D, 0x20, 0x66, 0x72, 0x6F, 
                    0x6D, 0x20, 0x61, 0x72, 0x6F, 0x75, 0x6E, 0x64, 
                    0x20, …
jonsca commented: Beautiful +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

So? If the value is not used before the cin , why do you need to set it to a value before that?

I know, it's a matter of personal opinion.

Then state it as an opinion. What you stated was a requirement... :icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Wut are question marks nerr.

And how about you read this (paragraph 1)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

thelamb gave you just enough for you to actually think about the change and do it properly. He did not give you a total solution...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Assuming you wrote Standard C++ it should work with only minor changes. If you didn't, you'll have to find another way of fixing the error (change in function, or even concept).

Start by compiling and fixing any errors that pop up.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
int size; // not assigning a value here
cin>>size;

So? If the value is not used before the cin , why do you need to set it to a value before that?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The system() command can't find Notepad. I'll bet it could find Notepad.exe though...

16 bit compiler?

Turbo C probably...

DOS command?

cmd.exe -- console. Many people still think of it as DOS.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

ok ok sorry for lack of info....
The errors i got after compiling the program are indicated as comments.....

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>

int chkcol(int u[x][y]);[B]//size of the type is unknown or zero[/B]

int chkrow(int v[x][y]);[B]//size of the type is unknown or zero[/B]

int chkbox(int w[x][y]);[B]//size of the type is unknown or zero[/B]

Remove the x and y, leave the [] though.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Do not post help requests as Code Snippets.
Use CODE tags.
Don't post your email address.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

"My car won't go. Please help."

Do you think your mechanic could do anything with this information?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Resurrecting a 6 year old thread to post a question like this is asinine. Read the rules and start your own thread!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Or PKZip, 7Zip, Peazip, etc, etc...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Snobol is designed specifically for string manipulation

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Where do you calculate both roots? I only see one calculated.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

PS. I dont know what is in 1.txt, it could be any file, so I cant manually add one more slash.

You still have absolutely no idea what you are doing, even with all the help we've tried to give you.

The contents of the file have no bearing on whether you use \ or \\.

You'd better explain in extremely minute detail exactly what you want, exactly what you're doing, exactly what is happening, and exactly why you think it's not working.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You have to Package the program, not just compile it. This will set up a distribution package that includes all the other files the .exe needs in order to run.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you want a list of all the files on your he you don't need the \ character at all. Just this: system("dir c: /s > c.txt");

Yes you do. The command above will list files starting with the current directory -- probably from the location of the .exe file. system("dir c:\\ /s > c.txt"); will start listing from the root directory.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I assume that was up to the OP...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Detroit --> Deetrooit

More like Dee-troy-t

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Your country needs more medical training.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Is strcpy(windows,"dir :\/s/b/a-d> .txt"); part of your C++ source code? What have we said about \ in C++ source code? \\ in C++ Source code is a single character -- a single \.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Line 24: box(23,57,2,7);gotoxy(37,4);printf("IPHONE"); I actually ran it to see if the calculator looks good. It does... :icon_smile:

Ancient Dragon commented: Good. +26
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you are reading a file with the \'s in them, you have no problem. Same with typing the \ from the keyboard at one of your program's prompts. It's only when using the \ in a string in your source code that the double \ is needed.

And lima01, this is true for the language, not a specific compiler. Whether M$, DevC, g++, all compilers act the same.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

ok code is fixed... thinking that i need to use a boolean to convert to lowest terms ... getting lost in the how to take regular math thought to you programming language .... everything aside from the math is working now with no errors ... was thinking something along the lines of using something like this ... am I on the right track here...

for ( int i = 3; i <= num; i++)
{
for (int j = 2; j <= num; j++)
{
if ( i!=j && i % j == 0)

No.

More along the lines of

get lowest of num & den in loopval
set i to 2
while i <= loopval/2 
    if num%i = 0 and den%i = 0 then
        num = num /i
        den = den /i
        i = i+1

with soem thought on the loop to get it correct.... :icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Anytime you want a special character in a string, you use \x where x is the character. Therefore, the \ itself is a special character, too. So you must use \x format to add one -- hence \\

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

that worked but now I am getting a whole slew of new errors when I try to compile the same code on my home ubuntu machine

here are the new compiler errors:

assign6.cpp: In member function ‘char cAccount::get_accountName(char (&)[15])’:
assign6.cpp:24: error: ‘strcpy’ was not declared in this scope

So where is strcpy() defined?

assign6.cpp: In member function ‘void cAccountList::print_to_screen()’:
assign6.cpp:104: error: ‘strcmp’ was not declared in this scope

So where is strcmp() defined?

assign6.cpp: In member function ‘bool cAccountList::search()’:
assign6.cpp:148: error: ‘strcmp’ was not declared in this scope

So where is strcmp() defined?

Check your notes...