-
May 5th, 2013, 06:13 PM
#1
how to "Bold search result in C++"
hi,
i need to know, that how i can get search result in bold format(using sequential search technique) from an array, in C++ graphic mode ???
e.g.
here is an array : 2 4 5 34 0 -45
and search key == 34
when it found 34 in array, '34' should bold to be prominent.
regards.
pls reply soon.
thanks.
-
May 5th, 2013, 09:02 PM
#2
Re: how to "Bold search result in C++"
There is no such thing as "C++ graphic mode". However, there are ways to get text to be bold in a C++ program, but that depends on what exactly you have in mind (a console based program? A GUI?) and what library you're using.
-
May 5th, 2013, 11:00 PM
#3
Re: how to "Bold search result in C++"
thanks for the response.
i am using windows 7 64bit, and Turbo c compiler.
i have created a simple program in c++ graphic mode using library graphics.h, my program focused features are :
1) user will give values those will be store as an array, and when search button clicked on, a key will be ask to search and as search result i have showed the position(index) and count of the key value, but, 1 thing more to show is the part of my assignment that this key value should be appear in 'bold' format, if it exists in list/array.
2) i tried settextstyle() function for this purpose, but, it is not helpful. or may be i'm not using this function in proper way.
3) here given below is my code to perform search function, if you kindly guide me where and how i have to stick this function in this code;
cout<<"Enter a value to search : ";
gets(ch);
gotoxy(8,8);
cout<<" ";
gotoxy(5,9);
cn=valid(atoi(ch)); // check
if(cn==0)
{
gotoxy(8,8);
cout<<" ";
gotoxy(8,8);
cout<<"INVALID DATA......";
delay(700);
gotoxy(8,8);
cout<<" ";
gotoxy(8,8);
cout<<" ";
}
else
{
gotoxy(8,8);
cout<<" ";
gotoxy(8,8);
int number=atoi(ch);
searchno(number);
}
void searchno(int number)
{
int found=0, counter=0;
for(int i=0;i<posx;i++)
{
if(array[i]==number)
{
found=1; //indicator to check if found.
counter++;
//Bold(char text[i], int row, int col);
settextstyle(10,0,1);
cout<<number <<" found at Position ["<<i+1 <<"]" <<" and Total count of " <<number <<" is [" <<counter <<"] ";
}
}
if(found==0)
{
//gotoxy(30,3);
cout<<number <<" not found in the list.";
}
}
please guide me how to use this function or any solution else.
-
May 6th, 2013, 08:32 AM
#4
Re: how to "Bold search result in C++"
When posting code, please format with indents properly and use code tags (Go Advanced, select code, click '#').
If you can't do 'bold' format, why not just change background/foreground colour to 'highlight' the answer?
You might also want to look at
http://www.cprogrammingexpert.com/C/.../graphics.aspx
which has some examples of using graphics.h package.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|