how old r u when ur in the 8th grade (im in the uk)
about 13 or so -- and its been 50 years since I was in 8th grade :mrgreen:
how old r u when ur in the 8th grade (im in the uk)
about 13 or so -- and its been 50 years since I was in 8th grade :mrgreen:
why that doesnt work?
#include <stdio.h>int main ()
{
char lala ;
printf ("Enter string:");
scanf("%s", &lala);
printf ("%s\n", lala );
return 0;
}
1. please use code tags as shown in ~S.O.S~'s example.
2. you did not declare variable lala correctly -- study ~S.O.S~'s example and pay close attention to how he declared the character string.
3. NEVER usr scanf() -- it is harmful to your program's health because it will let you type in a string that is larger than the buffer you created for it, such as in your example. Use fgets() instead -- again see ~S.O.S~'s example.
most if not all those are for different human languages (english, french, german etc). There are also TurboDelphi, Trubo C#, Turbo C++ etc. Choose the version that is right for you
HI, I have exe file writen in c++ or c and wanna decompile it to source code.
Is that possible? If it is, is there any decompilet that can do that?thanks!
No, it is not possible to decompile back to C. The best you can do is get the assembly code. Since you lost the source code (and that happened to me a couple times too!) you will just have to rewrite it. That has some advantages because the second write ususlly makes a better program anyway because you already know most of the algorithms needed and you may be able to make them more efficient.
you don't really need sprintf at all. just use fprintf()
int cust_num = 123;
fprintf(fpr, "%d\n", cust_num);
// now if you want the number to have at least 5 digits, with leading 0s when needed
fprintf(fpr, "%05d\n", cust_num);
I apologize Walt -- I did not intend to edit your post. My screwup! :(
Actually, you read from one file, then write to another file. You don't want to read and write to the same file. It gets too complicated.
I did not suggest he write to the same file that he's reading. read the sudo-code again please -- "write to new file"
aha !
if i want to write to a file, do i have to fread it first or just
fwrite it straight away ?
thx champ
of course the program has to read it -- how else do you think it is going to be able to know where the commans are and what to write to the new file?
for each line in the source file
read a line
replace all commas with semicolons
write the string to the new file
end
badly formatted condional statement
if( (strcmp(ptr,"int")== 0) || (strcmp(ptr,"float") == 0) )
use strchr() to find the comma then replace it
char str[] = "Hello,World";
// find the comma
char *ptr = strchr(str,',')
// replace it if found
if(ptr != NULL)
*ptr = ';';
Now, put the above in a loop to find and replace all the commas in the string.
you mean people old enough to post on the internet still have a nanny? Isnt' a nanny just another word for a baby sitter?
yes -- but you have to write the program youself. We are here to help YOU write programs, not for us the do your work.
What does a timekeeper like shape look like ???
normally yes, write a thread-safe wrapper for the functions in the library. How to do that depends on the compiler and operating system you are using.
In the first chase y is just one single character, in the second case it is a string. This is not an example of what I was thinking about and you would be better off leaving it the way you have it. Something like below is what I was thinking
char buf[255];
in.read(buf,sizeof(int));
int x = *(int*)buf;
above could be rewritten like this, but I'm sure you probably already know that.
int x;
in.read(&x,sizeof(int);
I am using char arrays, because in the file i/o procedures, char arrays are required, and because I am typecasting them from char to int and you cannot typecast std::string, at least not in VC.NET.
depends. please post an example of what you mean -- there may be other better or more appropriate alternatives.
for (x=0; x <strlen(pword); x++)
{
file2.open(fname, ios::in);
file2.getline(stuff, 3);
file2.close();
cout << (char)okay;
}
What the H is the above supposed to do? What it IS doing is opening a file, reading the first line, the closing the file -- all that possibly hundreds of times (depending on length of pword). Why in the world would you want to waste so much CPU time doing the same identican thing so many times?
You are obviously writing a c++ program. Then why are you using C style character arrays instead of c++ std::string class? There are valid reasons for doing it, but I don't see any valid reasons in your program, unless of course (1) your instructore required it, or (2) you have not learned about std::string yet.
std::string uname;
std::string pword;
std::string fname;
I just successfully linked you program using these libraries:
lib/libodbc32.a
lib/libodbccp32.a
To add then to the project, use menu Project --> Project Options --> hit the Parameters tab, then put the library names in the Linker box.
you can not use the name of functions as the name of a variables. Function names must be different from variable names. Example: residential_rate is used both as a function name and a variable name, and since the variable name is in _tmain() the compiler is treating that symble as a float, not a function.
I don't know the answer, but I hope you realize that in many countries (like USA) recording telephone conversions is illegal unless (1) you have the permission of the person being recorded, or (2) you have a court order, or (3) you happen to be the President of the US (PM of England will probably do as well)
looks like a missing library. you probably need to add libodbccp32.a to library list.
threads were merged.
There are hundreds of free examples on the net, just google for "odbc c libraries". Here is just one of them
Or why not just compile the code you posted in your other thread?
you can use strtok() to extract the individual fields.
while( fgets(buf,sizeof(buf),fp) != NULL)
{
rSales[i].number = atoi(strtok(buf,","));
strcpy(rSales[i].item, strtok(NULL,","));
strcpy(rSales[i].partnum, strtok(NULL,","));
rSales[i].cost = (float)atof(strtok(NULL,","));
strcpy(rSales[i].day, strtok(NULL,","));
++i;
}
[edit] you might want to read Dave's links from this post[/edit]
>> i didn't get any reply
I don't recall seeing another post -- did I miss it?
1. is that a C or a C++ program? You include both stdio.h and iostream, yet you use C file i/o functions. Make up your mind which kind of program you want and stick to it.
2. the code does not even compile cleanly. before attempting to answer your question you need to fix all the compile errors, then repost the code.
3. next time please use proper indentation -- the code is terrible to read as it is now. I hope you don't write all your programs like that.
Oh well, just ignore my ignorance. I had something else in mind. Good discussion in that link you posted. :)
*process.h - definition and declarations for process control functions
*
* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* This file defines the modeflag values for spawnxx calls.
* Also contains the function argument declarations for all
* process control related routines.
*
* [Public]
*
****/
For linux you will use whatever header file declares the spawn() family of functions.
congratulations on passing the exam. May the money start flowing in from all around you :) :) :)
worst case: run it on an old 80x88 computer that has 0.4 MG CPU chip, if you can find it.
best case: run it on a cray computer
average: average the two above
seriously: the timings will all depends on the os and CPU you run it on. And you may have to run that code several million times before you can get any readable timings. Then run that 1,000 times and you will get the worst case, best case and averages.
your best bet for answers is to find a users-group that specializes in that language. Check out their web site to see if they have one posted.
I work with two women -- one is my supervisor and the other does the same thing as I do. Our company has several other women too, one has a Ph.D. of some sort.
I use IE6 at work and IE7 at home. Years ago I used Netscape, but the make a new version that I really hated and stopped using it.
The problem is that your program has several compiler errors and is badly formatted. Here is a correction
#include <stdio.h>
int bitcount(unsigned x);
int main(void)
{
printf("%d\n",bitcount(3));
return 0;
}
int bitcount(unsigned x)
{
int b;
for (b=0; x!=0; x >>=1)
{
if (x &01)
{
b++;
}
}
return b;
}
>>Is it something like this?
I don't know. You have not said what you want it to look like yet. You should compile and run your program to see for yourself whether it is right or not.
int locate(nd **head,int num){
nd *p;
p=*head;
while(p!=NULL)
{
p=p->next;
}
if(num==p->x)
return 1;
else
return 0;
}the code above always return to xero
Look and think about the logic in the code you posted, pay attention to the while loop. All it does is iterate through the linked list without stopping. The if statement needs to be inside the loop -- I did not tell you to move it outside the loop. The else part shoud not be there at all.
int locate(nd **head,int num){
nd *p;
p=*head;
while(p!=NULL)
{
p=p->next;
if(num==p->x)
return 1;
}
return 0;
}
almost there -- the else and return 0 should not be inside the loop. And move p=p->next; to the bottom of the loop.
Thanks! But it doesn't seem to get any output? Please advise.
Anything i should input to show output like f(5) = 5?
Thanks.
what output are you expecting? your program does not contain any code to print anything on the screen. For C programs use printf() function, c++ programs use cout class. See your text book for instructions about how to use these functions.
why is sum a linked list and not a simple integer?
int sum(nd **head){
nd *pl
int sum1 = 0;
p=*head;
while(p!=NULL)
{
sum1 += p->x;
p=p->next;
}
return sum1;
}
>> how to pass a string as an argument to a sub fuction
The same as you would any other data type
void foo( const char* some_string)
{
}
int main()
{
foo("Hello World");
return 0;
}
>>what is the maximum limit of subscripts that the character array can hold
See limits.h for maximum value of a signed integer.
does the code compile with no errors? It does not with my compiler. You have to fix all the errors before attempting to run the program.
>> void main()
main never ever returns void. The correct way to dealre that function is like this -- any other way is wrong.:
int main()
{
// your code here
return 0;
}
>>I'm not trying to pushback the string. I
If you read my example carefully I didn't push_back the string either.
>>At the end of the run, each vector has one too many numbers still
re-read my previous post -- I already told you that your loop is incorrect and I showed you the correct loop
the loop is formatted wrong. Crevat: atof() does not detect errors in the string, but it doesn't really matter if you know the strings are all formatted ok.
while( in.getline(ch, 256, '\n'))
{
numbers.push_back(atof(ch));
}
better yet, use a std::string instead of a char array
std::string line;
while( getline(in, line) )
{
numbers.push_back(atof(line.c_str));
}
there are several examples and tutorials. I suggest you use a structure to hold the data for one account then put the structures in an array. That helps keep all the data together when sorting and searching. The actual algorithm you are looking for is almost the same as shown in the link I posted. Just change the comparison to use string compares instead of integer compares.
piush_back is a method of the vector class --
vector<char> array;
array.push_back('A');
All c++ text books have examples of vector class and how to use them. You should read it.
we all understand your frustrations because everyone was a newbe at one time, but nobody is going to write your porograms for you. Post your code, post some of the errors and ask questions, don't just restate the problem.
>> the question is ...
No, that is not a question. Questions end in a question-mark ??????? A question often starts with the word "How" or "What" or "Why". "Write function of ..." is a statement, a command, an order. It is telling you want to do, not how to do it. If I tell you to mow the lawn (cut the grass) I am not asking a question but telling you what to do. If you don't know how to mow the lawn then you don't just repeat the order but instead ask something about what you don't understand.
Since I don't have my crystle ball with me today I can't read you mind and know what question(s) you want to ask.
[edit] Here is a short tutorial and example program[/edit]
what do you want to know about fractions? (see any 2nd grade math book -- if you are in college then shame on you!:mrgreen: )