Forum Replies Created
- AuthorPosts
- msaqibParticipant
I have been using godaddy.com to host my websites. It’s quite affordable and provides lots of extra services. Plus unlimited subdomains and host unlimited websites.
I also used brinksters but didn’t like it much.
msaqibParticipantAre you using turbo C++ compiler to compile and run your programs or what?
msaqibParticipantThe code
1while (fgets(line,100,infile)!=NULL)reads the file and function fgets() reads the file line by line. So when the program reads first line, it skips the first line of records which is
No Matrix quiz1(5%) quiz1(5%) quiz1(5%) Proj(25%) MidT(20%) Final(40%)
and is done by this code:1234if(x==1)<br />{<br /><br />}And you read all the marks and data in else part of the program.
123456else{<br />i=0;<br />while( fscanf(infile,"%d %s %d %d %d %d %d %d",&no<i>,matrix</i><i>, &quiz_1</i><i>, &quiz_2</i><i>, &quiz_3</i><i>, &project</i><i>, &midT</i><i>, &final</i><i>) !=EOF)<br />printf("%d %s %d %d %d %d %d %dn",no</i><i>, matrix</i><i>, quiz_1</i><i>, quiz_2</i><i>, quiz_3</i><i>, project</i><i>, midT</i><i>, final</i><i>);<br />i++;<br />}</i>msaqibParticipantUse fgets() function to read the file line by line and then split the string and store all the values in variables.
123456789101112131415<br />int x = 0;<br />while (fgets(msg,25,fp)!=NULL)<br />{<br />x++;<br />if(x==0){<br />//we do not need to read first line as it contians headings<br />//this is the first line which you don't need to read and you can hardcode it in progrm<br />}<br />else{<br />//write your rest of the program here to read the data and manipulate<br />}<br /><br />}<br />msaqibParticipantHelloYou are trying to use string type variable in your switch statement which is expecting an int type variable. Here is how you are doing
1234567string thirdn;<br />switch (thirdn){<br />case 1:<br />//code<br />case 2:<br />//code<br />}Now the problem is you can not use string type variable in switch statement. You could use it like
12345678<br />string thirdn;<br />switch (thirdn){<br />case "1":<br />//code<br />case "2":<br />//code<br />}Or you could have use int type variable like
12345678<br />int thirdn;<br />switch (thirdn){<br />case 1:<br />//code<br />case 2:<br />//code<br />}msaqibParticipantSomeone has already done the hard work for you :D. So you can use the same graphis.h functions and library. So what you have to do is, https://www.mycplus.com/tutorials/c-programming-tutorials/graphics-programming/ checkout this webpage, read through it, and download the gaphics library and graphics.h header file.
Next step is to read the manual on how to prepare you project to use this library. And thats it, you are done.
Here is a simple graphics program which i wrote for my Borland compiler 3. But the same program without any modifications is working fine on Dev-C++ 4.9.C12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576#include <stdio.h>#include <graphics.h>#include <conio.h>#include <process.h>int main(void){int mx, my;/* request auto detection */int gd= DETECT, gm, errorcode;initgraph(&gd,&gm,"F:\tc\bgi"); //Last argument is the path to the graphics library of Turbo C/* read result of initialization */errorcode = graphresult();if (errorcode != grOk) /* an error occurred */{printf("Graphics error: %sn", grapherrormsg(errorcode));printf("Press any key to halt:");getch();exit(1); /* return with error code */}mx = (getmaxx() / 2);my = (getmaxy() / 2);//SET baqckground colorsetfillstyle(9, 1);bar(0,0,getmaxx(),getmaxy());//DRAW a bar, and make it look like a 3d barsetfillstyle(1,7);//bar(50,20,600,400);//DRAW lines for the top and left sidesetcolor(15);line(50,20,600,20);line(51,21,599,21);line(50,20,50,400);line(51,21,51,399);//DRAW lines for the bottom and right sidesetcolor(8);line(600,20,600,400);line(599,21,599,400);line(50,400,600,400);line(51,399,600,399);//DRAW two 3D bars for the left and right sidesetfillstyle(9,8);bar(70,40,100,380);bar(70,40,550,70);bar(70,350,550,379);bar(545,40,575,380);settextstyle(1, 0, 4);settextjustify(1,1);setcolor(LIGHTGREEN);outtextxy(mx+2, my - 46, "Graphics - Dev-C++");setcolor(LIGHTGREEN);outtextxy(mx + 1, my - 45, "Graphics - Dev-C++");setcolor(GREEN);outtextxy(mx + 2, my - 44, "Graphics - Dev-C++");//PRINT 3D text 2008setcolor(LIGHTGREEN);outtextxy(mx, my + 10, "2008");setcolor(LIGHTGREEN);outtextxy(mx + 1, my + 11, "2008");setcolor(GREEN);outtextxy(mx + 2, my + 12, "2008");getch(); //PAUSE for a whileclosegraph();return 0;}msaqibParticipantHey
Yes I got the same error, this is not the compiler or OS error. Actually the variable choice in your program is of type int. And you use that variable to get the input from the user to make the decision and navigate through the menu. So now the problem is when enters character instead of an integer value, it crashes your program.So the solution to your problem is that you will have to check this input first, whether the choice is of type integer or character. If its of character type then ignore it, as you are doing cin.ignore(); but you will have to implement it properly. As cin.ignore(); ignores characters only.
msaqibParticipantHello
Well it’s quite strange then, because I am using the same compile, OS version. Do you exit the program when you press ‘0’? And then press Enter kay to exit the program?
I did the same thing, it worked fine here…
May be anyone else might help you out here. For me this program works fine.
I did not talk about smilies in the post, infact they are to show the feelings. I am talking about the language like
@Encrypted wrote:
nd i m usin windows XP SP2 ….
hwever it ddnt wrk even in windows 2000 …
nd 1 more thng…u r sayin its wrkn fine thru ur compilerYou could have written it like
and i am using windows xp SP2
How ever it did not work even in windows 2000…
and one more thing..you are saying its working fine through your compilesThis way it looks quite readable.
Thanks
msaqibParticipantHello
I have jsut compiled and run your program, and it works fine with me. I am using the same version of borland turbo c compiler on windows XP. It didn’t give me any errors or warning message and the program remained stable. Turbo C neither crashed nor closed with or without any warnings.
What operating system do you use?Note:
@Encrypted wrote:dis is my code…
now wen i run it, it runs well nd fine…widout ne problems…
but as sun as i exit it…instead of returnin to TC compiler, it jsts exits to d windows…
soo…now if u hav gotta time for it…den pls check it out…
nd giv me a reason nd solution…nd yaaa…i m using a Borland Turbo C compiler of version 3.0….thot it mite help u…
Please read the forums guidelines, as people would not understand this language, it looks like some sort of chatting language :P
But I would advise not to use it because it looks a bit odd and one can’t understand it easily.msaqibParticipantWhat operating system are you using?
I worked on Win 98, 2000 and XP. turbo C/C++ compiler has no problems while using on win98. But if you write code which try to directly access any I/O port like COM port, then it causes problems. Because win 2000 and XP has some restrictions on accessing these resources.So if this is causing the problem for you…then I would advise you to use either win98 or change your program in a way that can safely access I/O devices.
Or you could explain any situation when your program crashed, was that TC.exe file itself or you were trying to compile and run any program on TC?
msaqibParticipantHello
I have made few changes to your program and its working fine and shows all the details about the bitmap image. What I think is that you have copied and pasted the code from some other source, and there were some errors (might be pasting errors), that was the reason your program was not working.
OK! I have tested your program on MS visual C++ 6 compiler and working fine. Below you can find the working code for your program. As it was an MFc application so “stdafx.h” header file has been added. Also if you goto the line (54-56) you will find that some code is commented, I think that was not a necessary code and was also creating some errors of type casting. If you really need that code to use then you will have to get around with it through some other ways.
Because123int numColors = 1<<bitmapInfoHeader.biBitCount;<br />RGBQUAD rgbQuad[numColors];<br />you can not declare an array variable with dynamic size which can change at run time. You can use some other techniques like type casting. Rest of the code is working fine.
Oh one more thing, by default MS visual Studio environment creates a single threaded application where as the libraries used in this program are multithreaded so you might get some errors at run time. To run the program smoothly you will need to make few changes in project settings. You will need to perform the following tasks before running the project.
Change the application to multithreaded. To do this:
1. Go to Project Settings and select the ‘C/C++’ tab.
2. Select ‘Code Generation’ in Category.
3. Set Use run-time library to either Debug Multithreaded (for debug builds) or Multithreaded (for release builds).
Best of luck with your project.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195#include "conio.h"#include "stdafx.h"#include "iostream"#include "fstream"#include "windows.h"using namespace std;int CompressInRLE8(BYTE* pSrcBits, CByteArray& pRLE_Bits, int& RLE_size);BOOL EndOfLine(int pos);int main(int argc, char *argv[]){BITMAPFILEHEADER bitmapFileHeader;BITMAPINFOHEADER bitmapInfoHeader;ifstream file("test.bmp", ios::in);if(!file){cerr<<"File can not be opened"<<endl;exit(1);}file.read(reinterpret_cast<char *> (&bitmapFileHeader),sizeof(BITMAPFILEHEADER));if(bitmapFileHeader.bfType != 19778 )cout <<" This is not a bitmap (.bmp) file ....";else{cout << "sizeof Bitmap File Header =" << sizeof(bitmapFileHeader) << endl;cout << "size of Bitmap Image =" << bitmapFileHeader.bfSize << endl;}file.read(reinterpret_cast</char><char *> (&bitmapInfoHeader),sizeof(BITMAPINFOHEADER));if( bitmapInfoHeader.biBitCount != 8){cout <<" This is not a 8 bit bitmap (.bmp) file ....";}else{cout << "sizeof Bitmap Info Header =" << sizeof(bitmapInfoHeader) << endl;cout << "Height of this Bitmap Image =" << bitmapInfoHeader.biHeight << endl;cout << "Widht of this Bitmap Image =" << bitmapInfoHeader.biWidth << endl;int numColors = 1<<bitmapInfoHeader.biBitCount;//RGBQUAD rgbQuad[numColors];//file.read(reinterpret_cast</char><char *> (&rgbQuad),sizeof(rgbQuad));}return 0;}BOOL EndOfLine(int pos){DIBSECTION m_dib;if ( 0 != m_dib.dsBmih.biWidth % 4 ){int scanline_width = m_dib.dsBmih.biWidth;scanline_width = scanline_width + ( 4 - (scanline_width%4));pos %= scanline_width;}return 0 == ((pos+1)% m_dib.dsBmih.biWidth);}int CompressInRLE8(BYTE* pSrcBits, CByteArray& pRLEBits, int& RLE_size){DIBSECTION m_dib;int line;int src_index = 0, dst_index = 0, counter, i;// in RLE8 every pixel is one bytefor ( line = 0; line < m_dib.dsBmih.biHeight; line++){state_start: // just at the start of a blockif ( EndOfLine(src_index)) // this is the last pixel of the line{pRLEBits[dst_index++] = 1; // block of length 1pRLEBits[dst_index++] = pSrcBits[src_index];src_index++;goto end_of_line;}// now the block length is at least 2, look ahead to decide next state// next two same pixels are the same, enter compress modeif (pSrcBits[src_index] == pSrcBits[src_index+1])goto state_compress;if ( EndOfLine(src_index+1)) // the last 2 pixel of the line{ // these 2 pixel are not the samepRLEBits[dst_index++] = 1; // block of length 1pRLEBits[dst_index++] = pSrcBits[src_index++];pRLEBits[dst_index++] = 1; // block of length 1pRLEBits[dst_index++] = pSrcBits[src_index++];goto end_of_line;}// now the block length is at least 3// in next 3 pixels, the last 2 consecutive pixel are the sameif (pSrcBits[src_index+1] == pSrcBits[src_index+2]){pRLEBits[dst_index++] = 1; // block of length 1pRLEBits[dst_index++] = pSrcBits[src_index++];goto state_compress;}else // in these 3 pixel, no 2 consecutive pixel are the samegoto state_no_compress; // un-compressed block need at least 3 pixelstate_compress: // compress mode// src_index is the first pixel of a compressd block// counter is the number of additional pixels following currrent pixel// (src_index+counter) point to the last pixel of current blockfor ( counter = 1; counter <= 254; counter++){// must check this condition first, or a BUG occur!if ( pSrcBits[src_index+counter] != pSrcBits[src_index] )break;if ( EndOfLine(src_index+counter) ) // reach end of line{pRLEBits[dst_index++] = counter+1; // block length is (counter+1)pRLEBits[dst_index++] = pSrcBits[src_index];src_index += counter +1;goto end_of_line;}}// now pSrcBits[src_index+counter] falls out of blockpRLEBits[dst_index++] = counter; // block length is (counter)pRLEBits[dst_index++] = pSrcBits[src_index];src_index += counter;goto state_start;state_no_compress:// src_index is the first pixel of a un-compressd block// un-compressed block need at least 3 pixel// counter is the number of additional pixels following currrent pixelfor (counter = 2; counter <= 254; counter++){if ( EndOfLine(src_index+counter) ) // reach end of line{pRLEBits[dst_index++] = 0; // escape character for un-compress blockpRLEBits[dst_index++] = counter + 1; // block length is (counter+1)for (i = counter + 1; i > 0; i--)pRLEBits[dst_index++] = pSrcBits[src_index++];if ( 0 != ((counter+1) % 2) ) // block length is oddpRLEBits[dst_index++]; // padd with a zero bytegoto end_of_line;}if ( EndOfLine(src_index+counter+1) ||pSrcBits[src_index+counter] != pSrcBits[src_index+counter+1] )continue; // still no 2 consecutive pixel are the same,// therefore continue to extend the un-compress block// we found two pixels are the sameif ( EndOfLine(src_index+counter+2) ||pSrcBits[src_index+counter+1] != pSrcBits[src_index+counter+2] )continue; // the third pixel is not the same, no need to exit un-compressed modeelse{ // // now pSrcBits[src_index+counter] and following 2 pixel are the same// now we need to exit the un-compressed modeif ( counter > 2)counter--; // we can shrink the block one pixel (go backward)pRLEBits[dst_index++] = 0; // escape character for un-compress blockpRLEBits[dst_index++] = counter+1; // block length is (counter+1)for (i = counter+1; i > 0; i--)pRLEBits[dst_index++] = pSrcBits[src_index++];if ( 0 != ((counter+1) % 2) ) // block length is oddpRLEBits[dst_index++]; // padd with a zero bytegoto state_compress;}} // end of for (counter = 2; counter <= 254; counter++)// now we have a full block of 255 pixelspRLEBits[dst_index++] = 0; // escape character for un-compress blockpRLEBits[dst_index++] = counter; // block length is (counter)for (i = counter; i > 0; i--)pRLEBits[dst_index++] = pSrcBits[src_index++];if ( 0 != ((counter) % 2) ) // block length is oddpRLEBits[dst_index++]; // padd with a zero bytegoto state_start;end_of_line:if ( 0 != (src_index % 4 )) // each scan line is dword align{int pad = 4 - (src_index%4);src_index += pad;}// src_index already point to the start of next linepRLEBits[dst_index++] = 0; // mark end-of-linepRLEBits[dst_index++] = 0;}pRLEBits[dst_index++] = 0; // mark end-of-bitmappRLEBits[dst_index++] = 1;RLE_size = dst_index; // image sizereturn 0;}</char>msaqibParticipantHi
Please provide a proper working link.msaqibParticipantSecure File Transfer is a secure way to move business critical files between almost any two computers across the networks. Its just a service which is provided by third parties, and one person upload the files to the thirdparty’s server and which is later picked by the other person. And the third party may apply extra security features on the fliles including encrypation, passwords, access level etc..
msaqibParticipantHere is the program you are looking for. That program actually does the color and background color change but also blinks the text.
- This reply was modified 9 years, 5 months ago by msaqib.
- This reply was modified 3 years, 9 months ago by M. Saqib.
msaqibParticipantHello,
How come you know me? yes I am from pak and I am the webmaster of this website.
- AuthorPosts