>simply wouldn't compile without explicit typecast to (char*).
Which compiler are you using??
ssharish
>simply wouldn't compile without explicit typecast to (char*).
Which compiler are you using??
ssharish
Well why dont you use a library function from math.h.
#include <math.h>
...
...
sqrt( 4 );
ssharish
Thanks guys for the reply. Yeah it seems it so difficult to get a job at the movement. Well i never use to call agencies before. Let me try that. Let me call quite often and kill them lol. See if they at least response from that.
>Have your other class-mates found work yet?
Well, there are few people who have already got the job. It do get lots of vacancies to work on .net environment. But I don't want to start my career there. And hence and keep avoiding them. Most of my friends and class -mates who got the job are all working on .net.
But I would like to work on C or C++ programming. If I could start it from there.
>What about your college, do they have a careers advice center as well for recent graduates?
Yeah the university has a career service center. They do have quite a few vacancies, I have applied for them.
The one more problem, which I seem to have is my current visa status. I am on student visa. But I am in the process of renewing it to PSW something similar to IGS. But most employers don't know about PSW and they don't even take my application take further.
What they should understand is that i am still eligible to work in here for next 2 years with PSW! :(
ssharish
Hello everyone,
I finished my graduation degree 2 months before and I was in the process of applying for a job. It been two months now. I just had three interviews. Its so frustrating. Why would I get a job.
Can anyone give me some advice on why does it happen. People who is been already employed, how did your interview go, where did you find the vacancies from. I am currently located in UK!
I have posted my CV on most of the public websites. I get calls from agencies and they get all my details. But they never get back later. Is it because of my lack of technical skills. I do apply for job directly through employer websites. But still I don't get reply very soon!
ssharish
Haha, here we have one more homeword thread?
Dapsigar, show us a bit of progress on this assignment. You could expect some more help!
ssharish
Well converting hex to binary is just problem. But there is one more reason. It is difficult to remember the binary pattern. So we group them to form it small number which still referees the same binary patten. There no any reason on why do we have to convert it binary to hex. At at least i havn;t come across any application which need a that feature!
ssharish
accho, as I said before, writing data onto a file either in binary or ascii is not gonna make a difference apart from few kila bytes. If your are really considered reducing the file size you need to think of compress the file.
If you still wanting to handle data with the bianry, then look back my previous post or if you are deling with the ascii then the function which u have been using are right, but should go though the manuals of those function to find out for a proper usage.
ssharish
Jamshed
Let me honest and polite with you. No one is gonna help you, if you don’t show us what have you have got so far. You need to show some progress.
By the looks of it, it’s not a job which can done straight ways. It would take few hours to get this system working. Or for you, since you’re just a beginner you might take take days to complete.
Ok, let me help you in getting started. From the problem what I can see there, you need to know few concepts like File handling, structures, array. Do you know any of these concepts?
But any way, here are few links for you to get started.
Structures: http://www.cprogramming.com/tutorial/lesson7.html
Arrays: http://www.cprogramming.com/tutorial/lesson8.html
File Handling: http://www.cprogramming.com/tutorial/lesson10.html
Once you are confident, post back. We might be able to help further.
ssharish
Try atof. See if they get the same answer. As said before it an implemenation issue.
ssharish
You could actually solve this problem using the fgets and sscanf function. These two function would do all things which you are looking for. Perhaps, you will have answer the Salem's question for you could implement it.
ssharish
Well, i could see some other problem as well now with that code. Can you please post the error message please
ssharish
#define GCD();
Take of that semicolon from that statment. Macros donst need a semicolon. If your marco definiation are like too big then you might use a '\' to speak it up and concatenate.
But for you just the semicolon off.
ssharish
pLike, you should really consider looking at on how to indentent you code first. Well the error message you get there is basiclly specifying that GetInteger cannot be assigned to the interger. It donst know what the RHS is? Seems to me like it is function or is it macro if there was no brackets ????
#include <stdio.h>
int main()
{
int a, b, c, x, y, z;
printf("Enter A: ");
a = GetInteger();
printf("Enter B: ");
b = GetInteger();
printf("Enter c: ");
c = GetInteger();
z = ( b * b - 4 * a * c );
x = ( ( -b - z ) / ( 2 * a ) );
y = ( ( -b + z ) / ( 2 * a ) );
if ( x == y )
printf("There is one solution: %d", x);
else if ( x != y )
printf("There are two solutions: %d and %d", x, y);
else
printf("There are no solutions");
system("pause");
return 0;
}
And the in the if statment, there two two equals opeator not the assignment operator if ( x == y )
ssharish
I don't think, it does make any big difference in writing the values into the file in either ASCII or binary is going to give you any difference in terms of file size. It all the same as far i can see.
Yes, there are function and routines which you could use to write data on to the file in binary mode. First of all you need to open the file for writing in binary mode. And then you will use fwrite and fread function to write and read respectively onto the file.
Perhaps you might also use fseek and ftell function position the file pointer to the right location in the file.
ssharish
YES, you need to allocate memory for msg before you copy the string on to msg. Failing to do that will lead to a Segmentation fault.
ssharish
It has nothing to do with IPC.
Just use process inheritance (CP)
He did ask, on how to create process and stuff. The link should give him an idea. Perhaps Salem's solution seems the best!
ssharish
Well, you could actually return of type double from your factorial function. You could have the denominator float as well to produce the right result. So try with return double and some modification in the factorial function by changing the data type of variable "fact" and do double calculation there instead of int.
And what inputs are you giving for variables x and n?
ssharish
Well, you need to do some error checking there. Thats not a complete code as I said before. You need to work upon it. You need to do some error checking there. Anything divided by 0 is 0. What are the input values did you give?
ssharish
>dry runs
True, should have notices that key work.
ssharish
I am sorry, i dont have any problem. Its your problem that you dint read the form rules before asking for help!
ssharish
May be you should really consider lookin back the sticky thread on top of this form.
Is it your homework my friend????
ssharish
Well, when I refer CPU I mean the cabinet!!!! It could be anything within the cabinet the ports, MB, memory anything etc.
ssharish
#include<stdio.h>
#include<math.h>
int factorial( int );
int main()
{
int n;
double x,i;
double value, sinx;
value = sinx = 0.0;
printf("Enter the value for x and i");
scanf("%lf %d", &x, &n);
for( i=1; i<=n; i=i+2)
{
value = pow(x,i);
sinx += (x - value / factorial(i));
}
printf("Result - %f", sinx );
getchar();
return 0;
}
int factorial( int n )
{
int j, fact=1;
for( j=n; j>0; j-- )
fact = fact * j;
return fact;
}
Where is your code indendation and the code tags. There where quite a lot of mistakes which you have done in the code. Have a look at the above with some slite modification. If you don understand ask!
ssharish
Well, the pesudo code should be converted to a code and then try with some test input.
Well, YES, you cant just compile a pesudo code. So on what language are you suppose to implement the pesudo code. There are few tools which converts the pesudo code to code. But, you will have to learn the pesudo code standard and which that specific tools can understand.
Some hint on the looks like Yacc, Yapp. Wel those tools are used for compiler design but you cant use it for your application. They understand a notation called BNF.
That should give an idea. YOU WILL HAVE TO IMPLEMENT THE CODE TO TEST IT.
ssharish
Shouldn't that be either (*iter).name
or iter->name
ssharish
Ohh man, you need to properly indentent your code. It so difficult to go through with that code.
Identent your code, you might except more help.
And what is '#' char in each line? Dosnt look good!
ssharish
Well, if you dont see your num light on the keyboard, then the power stuff to that key board is not give. Is it possible to check that keyboard with the different computer and see if your see any LED's lit up.
This is to just make sure that if the problem is with your keyboard or the CPU. If it does get a light lit up on your keyboard after connecting on to a different CPU then the problem is with the CPU, especially with the PS/2 or the USB which ever keyboard connector your using.
ssharish
You perhaps have a look into a concept called Inter Process Communication (IPC) Have a look at the following tutorial.
You create a new process by call a function called fork() and you start a new program within that process using a exec family functions.
Have a look at this link
http://www.ecst.csuchico.edu/~beej/guide/ipc/
ssharish
If you define a function properly and then go to use it and get an error while using it (a typo or something), you don't have to define the function again.
Well, why dont you get a good IDE and start coding in there. I IDE which I have been using is pyscripter. Thats a cool IDE with lots of updates now and then.
ssharish
Well, that gonna be difficult using the system function, since the function doesn’t return anything expect the status i.e 0 or 1.
What you could do is pipe the output to a file and access that file to get the output of that program.
Or you will have to fork a new process and run the program in that new process and pipe or redirect the output of the child process as an input to the parent process.
ssharish
Is this machine, connected to any domain controller?? I some cases the keyboard donst get recoganised you might well have to restart the computer once again. In order to recoganise. Do you see any power light on the keyboard i.e the num lock key on your keyboard lit up?
Alternatively start your computer with the safe mode and see if you can do something from there!
ssharish
Well, I should say that, I don’t even understand on what your are trying to do here. You will have to give some more information. And your code i just such a lot of mess. You are using stuff which you shouldn't be. Few which i pointed out.
1. Using a very old compiler
2. for(i=0;i<79;)
--> why are you not incr i ( include i++)
3. goto
<-- dont you know that these statement shouldn't be used. Its a bad programming practice.
4. gotoxy
is not a standard C function
5. and clrscr getch
!
6. Code indentation is horrible. But I thought this time I will do it for you
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void pos(char);
void text();
int i, j,k,x=0,y=0,s=0;
char txt[41][79],st[79],ch;
int main()
{
clrscr();
for(j=0;j<41;j++)
for(i=0;i<79;)
txt[j][i]=32;
text();
return 0;
}
void text()
{
for(j=0;j<41;j++)
{
for(i=0;i<79;)
{
ch=getch();
if(isalpha(ch) || isdigit(ch)|| ch==32)
{
x++;
i++;
txt[j][i]=ch;
putch(ch);
}
else
if (ch==13||ch==0)
{
pos(ch);
}
else
if (ch=='=')
goto last;
}//end of for
y++;
}//end of outer for
last:
}
void pos(char ch)
{
if(ch==13)
{
for( int k=i;k<=76;k++,s++)
st[s]=txt[j][k];
y++;
x=0;
printf("\n");
puts(st);
for( int t=j;t<41;t++)
{
for(int i=0;i<=78;i++)
{
putch(txt[t][i]);
}
printf("\n");
}
}//end of enter
if(ch==0)
{
ch=getch();
if(ch==72)
{
y=y-1;
gotoxy(x,y);
}
else if(ch==80)
{
y=y+1;
gotoxy(x, y);
}
else if(ch==75)
{
x=x-1;
gotoxy(x,y);
}
else if(ch==77)
{
x=x+1;
gotoxy(x,y);
}
}
}
ssharish
>Well, I was rewriting it to GLUT anyway. Thanks for the trouble. Suggestions on how to improve the above code are still welcome of course...
Perhaps, placing all your macros definition at the top the code would make it more be neat and professional. That was from a quite glance. That’s a huge lot code!
ssharish
void printB( int num )
{
if( num == 0 )
return;
else
{
printB( num / 2 );
printf("%d", num % 2 );
}
}
You could solve the problem of you binary values printing in reverse using the recursive function. Have a look the function above. You could see the before the function is called again it pushes the "num % 2" to the stack and when it return it print the values which is on top of the static that is "0%2" ........ "num%2".
Call the function as follow:
printB( 23 );
/* my output
10111
*/
NOTE: I wonder this would work for a long decimal number, due to overflow!
You might as well, look into some concept of code indendation, that code which you have posted has a horriable indendation! And it also give a me a nasty taste of you using a very old Turbo C compile??? Start looking at some better compiler. DEV-C++, Code::block
ssharish
OK, I here is a good link from microsoft, which walks you through on how to get started with the serial programming using win32 API.
http://msdn.microsoft.com/en-us/library/ms810467.aspx
This allows you to read and write data to your serial port. You might perhaps look for tutroila on "RS232 programming in C"
ssharish
Perhaps, you should have posted this question on a C++ form :-/.
And few things which I saw in your code, which you might have to consider to correcting
#include <stdio.h>
to
#include <cstdio>
And main should return a value. Well, it’s already if you don’t specify it as well, under C99 it automatically assumes to be return 0. But it is always a good practice to place them explicitly.
system("PAUSE");
Using system function is not very portable. You might have to consider using some different function. Have a look this thread
http://www.daniweb.com/forums/thread90228.html
NOTE: I still wonder why do you consider including
#include <iostream>
and
using namespace std;
You are just mixing up languages. Did anybody guide you to do that??
ssharish
I don’t have much to say, b’cos most of the clues on why this happened has been already pointed out. But the main cause for this problem is when you run the code once and then try running it once again or compile or rebuilt it. You might have to make sure that the program has exited properly. Use the processor explores windows to check if the process is still running.
You might be doing something wrong in your code may be. See if you your program exits properly. Salems link for processor explore is a very good tools to check to make sure if there are any other process having of your code file etc.
On my research it seems that, this is a known issue which the VS team is already aware of. Got this information from the following link? But still make sure that by disabling all antivirus software and run it again.
http://connect.live.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=292259
You might find this link useful as well.
http://support.microsoft.com/kb/308358
ssharish
I would be more helpful if you could say on what platform are you working at the movement? Its different to Linux and on windows!
ssharish
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim Test As New Form4
Test.Show()
Me.Dispose(False)
End Sub
Wouldn this made the code system to be still running even after closing the form2??? Since the form1 has been disposed. For it i think it should disposed when you close the form2 but it dosn't, which is a problem!
ssharish
Shankhs, what you have done in the main code is that, you have declare two char pointer, but the pointer itself cannot store the string which you have typed. What you can store is an address of a variable of type char.
So you will have allocate enough space to hold string which the user is gonna type. So by allocation like as follow
char name[80];
You allocate 80 bytes to store name. But practically speaking you don't need to 80 bytes to just store a name. No person have just huge name or at least as far i know. That the main problem in your code. It would be better of to gave just char name[25] which can hold up to 25 chars. And replace all your gets function to fgets.
Have look at strings concepts.
ssharish
OK, this question seems a pretty simple at first instance, but there are lot many things which need to be considered while coding this part. There are several ways to solve this problem. One of simple way ways is to coding this on some event, like a button click on something like that:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
Form2.Show()
End Sub
This is something which you can find it very easy. But you might also try adding the same codei the from1.load event. This code donst work as expected. Why?? Becase the form1 seems to the parent thread there and you cant close it or your cant hide .If close the form1 you are closing the whole project. You do a hide by just hiding it on to the system tray.
This is something which I did know already. Being said that I not windows programmer!
ssharish
Not really very sure why check if the line has a '\n' char in the buffer. It's obvious the fgets i gonna really until '\n' or EOF as per the specification of fgets.
This is what i thought when i posted.
while( fgets( buffer, sizeof buffer, fp ) != NULL )
line++;
ssharish
And also there are few things which you need to look back again, and try avoid using function like getch and gets function instead use getchar and fgets function which does the same job like what the former one does. It just the matter of standardization and portability.
And don't cast the return type of malloc, there is something called internal ,typecasting which will type cast the return type for you. Makes your work more easy and convenient.
ssharish
Hmmmm that was good question, it need a 2 min think before we could answer that question. I never an interview question like that before. But that was good one.
I don't see any improvements when we could do to that code. Everything seem to be good. And I do think 7 needs to be there if you wanted check the last 3 bit of a to check if they are set.
And again it all depends upon the requirement!
ssharish
I was about to suggest to use fgets function, but AD had already have a post on it. Using a fscanf function is also a good idea.
But only other thing which you might have to do if your using fgets is that, you will have to token the string and then convert that from string to an integer.
But when you use fscanf, you don't have to worry anything about type casting, since the fscanf function will do it for your, provided if you read the value as an integer.
Using fseek is more complicated and normally used when files are open in "b" mode. More over, it quite often used to read chunk of data like whole record or a structure. For example student records 1 and so on.
It would a good start if you could start reading it through fscanf or fgets and make your way through to try reading it through fread.
ssharish
Perhaps, you could have a look at a fgets function, which actually reduces few lines of code, but still does what you wanted to do. Have a look at that function. This is just to give you some more clarity for your code.
ssharish
Well, let me make it as brief note, but not too much information. All these should be researched on the web. There are plenty notes on these concepts on the we. But anyway.
A function can be thought of a group of statements which does a specific job for you. So for example, if you take remote control, the controller itself has many different functions in it. Each button on the remote does some specific job. But the whole device it self is called as a remote controller.
In the same way, functions are meant to designed or implemented to do some specific job. These can be function could call many other different functions to get their job done. You might also come cross a word “divide-conquer”. There are two different sort of function which you could come across user-defined function and library functions. The following is the prototype for an declaring a function in C
<return type> function_name( arguments )
{
<statement 1>
<statement 2>
<statement 3>
.
.
}
Example:
const double Cal_Square( const double num )
{
return ( num * num );
}
int main()
{
printf( “%f”, Cal_Square( 10.8 ) );
return 0;
}
As you can see from the above example, Cal_square is function which is called in main to get the square for a given num. The function calculates the square and returns the results back to main and result is printed out.
The function can extended to …
#include<stdio.h>
struct student
{
int id_no;
char name;
int average;
};
int main()
{
struct student stud1;
do
{
printf("Enter Index No : ");
scanf("%d",&stud1.id_no);
printf("Enter name : ");
scanf("%s",&stud1.name);
printf("Enter average : ");
scanf("%d",&stud1.average);
printf("\n");
} while( stud1.id_no != 0 );
return 0;
}
Where is your indentation my friend. This time I've done it for you. But don't ever expect that next time. Otherwise you wont expect any help from here. I am afraid.
Back the problem, well the program had been designed to get as many details from the user until the user enters 0 for student_id.
} while( stud1.id_no != 0 );
So what are you trying to achieve. If you could give us more information. we might be able to give some solutions and ideas. And the above snap of code is the one which you should be looking at. The reason it goes on forever asking details is because the the scanf statment are kept inside the do-while loop. Until the loop condition break you will asked for student details. If you just need to get one student details, then perhaps you should remove all those printf's and scanf's function out from the do-while loop and take off those loops completely from there.
ssharish
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str;
cout << "Please enter full name: ";
getline(cin, str);
cout << "Thank you, " << str << ".\n";
cin.get();
return 0;
}
/* my output
Please enter full name: hello
Thank you, hello.
*/
Seems to work for me. What compile are u using. Try to place endl at the end cout and see if that makes any different. May be its something to do with just flushing!
ssharish
A bytecode is set of instruction which is generated the by a java compiler. This bytecode can then be ported to any machine regards of the on what platform and processor architecture of the target machine is! The bytecode will then be interpreted by the Java Virtual machine (JVM) which then internally creates a binary which can then be executed by the local machine or whatever the processor architecture which the local machine has been implemented. The JVM holds the complete system spec. So that when it interprets the byte code it knows on what platform its working and what sort of binary it has to produce.
But when we speak about binary, it is something which the compiler generates it for us. When you compile a C code by a C compiler, example GCC, it created .exe file or a binary file which can then be executed. The GCC doesn’t create byte code instead it creates a binary. But what you should remember is that, when you compile your code for your embedded system, you should compile your code to get the binary which can then be executed by the processor which is there on the embedded board but not our host machine.
Because those both are completely different in terms of processor architecture. But thanks for the GCC. It can create binary for a wide range of processor. And hence it’s called native compile. The compile which can generate binary for specific processor architecture is called …