Hi to everyone , I am learning C language and I have problem with one example from book
Code:
#include <stdio.h>
int main()
{
char me[20];
printf(“What is your name?”);
scanf(“%s”,&me);
printf(“Welcome, %s!\n”,me);
return(0);
}
Code:
when I want to compile returns me
whoru.c: In function ‘main’:
whoru.c:6: error: stray ‘\342’ in program
whoru.c:6: error: stray ‘\200’ in program
whoru.c:6: error: stray ‘\234’ in program
whoru.c:6: error: expected expression before ‘%’ token
whoru.c:6: error: stray ‘\342’ in program
whoru.c:6: error: stray ‘\200’ in program
whoru.c:6: error: stray ‘\235’ in program
whoru.c:6: warning: format not a string literal and no format arguments
It looks like the quotes are wrong (i.e. incorrect characters). This sometimes happens when copy&pasting from browsers and certain word-processors. Make sure that you use " (ASCII 34).
Cheers,
Andy Barry
Nooleus.com
App Launcher for Sys Admins
There are "wide" characters in your C script. Possibly due to locale settings.
Valid characters in C are ASCII 0 -> ASCII 127, single byte characters - you have an octal 342 character in your code script which is way outside those bounds, for example.
Change those formatted quotes to straight quotes and remove the &
scanf() with strings do not receive an & since it is a pointer to the first character already.
Either
Code:
scanf("%s", me);
or
Code:
scanf("%s", &me[0]);
But the fact is that for getting string input from user, scanf() is a poor choice.
hi guys i have linked my lab 15. i have no idea where to start i dont understand whats it asking me. about the screen shot part!.. if someone can take a quick look and help me out with this unix lab that would be great..
i have did the
Required Errorlevels
Errorlevel #Event Information
... (1 Reply)
Hi i have recently downloaded the cygwin emulator on my windows xp machine and i installed it onto my laptop and all was fine. The thing is i have never known how to use it really. I am wanting to use linux on windows since i have some programs that work on linux only.
I have a program called... (1 Reply)
This is my first attempt in installing a netbsd ever. I'm trying to get myself familiar with some commands and how things work in unix and so far i never knew its this fun. Anyway, unix is our elective here in school and school is gonna start 2 weeks. I'm just trying to get a headstart on this :D... (2 Replies)
I've just begun using/studying Unix and I've run into a problem. I'm attempting to write a script that will replace a string within a textfile with another string, backing up the file before editing it.
This is what I have so far, but I'm getting a "command not found" error.
example input: ... (2 Replies)