15,911,785 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Navid Rigi Ebrahimi (Top 11 by date)
Navid Rigi Ebrahimi
12-Feb-23 8:42am
View
yeah, i know. i wrote sth to print all the chars below space, but no luck in null, which is a non-printable, like \n or \t or others.
Navid Rigi Ebrahimi
12-Feb-23 6:57am
View
Allowed functions : write
• Create a function that displays a string of characters onscreen. If this string contains characters that aren’t printable, they’ll have to be displayed in the shape of
hexadecimals (lowercase), preceeded by a "backslash".
• For example :
Coucou\ntu vas bien ?
• The function should display :
Coucou\0atu vas bien ?
• Here’s how it should be prototyped :
void ft_putstr_non_printable(char *str);
Navid Rigi Ebrahimi
12-Feb-23 5:07am
View
Yeah, it's the only way. Thanks a lot man.
Navid Rigi Ebrahimi
12-Feb-23 5:06am
View
All you said is correct and I know it, but as I said, it's in a question. It asks us to print those control characters.
Navid Rigi Ebrahimi
12-Feb-23 4:01am
View
Yeah, exactly but I have no idea how to fix it. Even sizeof doesn't work because first one refers to array but second one to pointer.
Navid Rigi Ebrahimi
12-Feb-23 3:49am
View
I want to print non-printable chars in the middle of string. It's in a question I'm solving right now.
Navid Rigi Ebrahimi
12-Feb-23 3:16am
View
int main()
{
char str[] = "Coucou\rtu vas bien ?";
str[6] = 0;
printf("%zu\n", sizeof(str));
ft_putstr_non_printable(str);
write (1, "\n", 1);
}
void ft_putstr_non_printable(char *str)
{
int i;
// int len;
char *chars;
i = 0;
chars = "0123456789abcdef";
// len = ft_strlen(str);
printf("%zu\n", sizeof(str));
while (str[i] != '\0')
{
if (str[i] >= 32 && str[i] <= 126)
write (1, &str[i], 1);
else
calcs(str[i], chars);
i++;
}
}
void calcs(char c, char *chars)
{
char i;
char j;
i = chars[c / 16];
j = chars[c % 16];
write (1, "\\", 1);
write (1, &i, 1);
write (1, &j, 1);
}
Navid Rigi Ebrahimi
8-Feb-23 4:20am
View
great, thanks
Navid Rigi Ebrahimi
12-Jan-23 14:46pm
View
Yeah, now I understood that 👍😉😄
Thanks man for your answer 👌
Navid Rigi Ebrahimi
12-Jan-23 14:35pm
View
Yeah, it works and shows the number. I thought that would be harder and trickier.
Navid Rigi Ebrahimi
12-Jan-23 14:35pm
View
It works and shows the result but I wasn't sure about it. I didn't think that to be so easy.
Show More